문제

I am doing a set of 301 redirects in Drupal.

I am using a standard method in the .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine on

Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
</IfModule>

but the return url ends up with "?q=user" and stops it working. eg:

http://thesitedomain.com/about?q=user/about

I am not great at htaccess redirects (obviously) and I am no Drupal expert at all.

Also, if you know of a comprehensive htaccess rewrite resource I would much appreciate reading hat.

도움이 되었습니까?

해결책

You will need to use mod_rewrite instead to strip out existing query string:

RewriteEngine On

RewriteRule ^user/testimonials/?$ http://thesitedomain.com/testimonials? [L,NC,R=301] 
RewriteRule ^user/contact/?$ http://thesitedomain.com/contact? [L,NC,R=301] 

Take note of trailing ? in target that strips out existing query string.

다른 팁

I can't speak to drupal, but I know you don't need to enclose those redirects in the <IfModule mod_rewrite.c> tags, since they don't use the RewriteEngine, the below would suffice:

Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact

Are both urls in the same drupal? Or are you moving from a different site? I mean:

Maybe what you need is to add an url alias for /user/testimonials like /testimonials

See under admin at /admin/config/search/path in drupal 7.

Using .htaccess file is not a good practice, because, in some updates you have to update the .htaccess file too.

You can try GlobalRedirect module to manage your redirects.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top