: 301 redirect behavior in a drupal system I am migrating an older site to a newer one which is using Drupal. As part of this I am trying to setup some 301 redirects to the new pages but
I am migrating an older site to a newer one which is using Drupal. As part of this I am trying to setup some 301 redirects to the new pages but I am getting some unexpected behavior. I added the following line to my .htaccess file:
redirect 301 /redirect.html www.example.com/newpage
Unfortunately, what happens is that I get taken to:
www.example.com/newpage?q=redirect.html
Which of course doesn't load correctly. Any thoughts?
More posts by @Gonzalez347
4 Comments
Sorted by latest first Latest Oldest Best
We used to Path redirect module for that purpose. It can't handle all powerful things that Mod_rewrite can, but it's done a really nice job for us at preserving old URLs.
Forget .htaccess. Use the global redirect. It gives you the following:
Checks the current URL for an alias and does a 301 redirect to it if it is not being used.
Checks the current URL for a trailing slash, removes it if present and repeats check 1 with the new request.
Checks access to the URL. If the user does not have access to the path, then no redirects are done. This helps avoid exposing private aliased node's.
It simplifies migration of your website slightly, and probably most important, it makes it simple to look up exactly what is being redirected where. (as there is a user interface for it)
Bonus (imagine clippy popping up here)
You seem to be creating something similar to clean URLs. I think you might be interested in pathauto.
So after a bit of searching, I found the answer here. It is similar to danlefree's but slightly diffrent.
<IFModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# custom redirects
RewriteRule ^redirect.html$ www.mysite.com/newpage [R=301,L]
# end custom redirects
...
</IFModule>
This seems to get the job done.
Your other rewrite rules are interfering.
Try the following instead:
RewriteEngine on
RewriteRule ^/redirect.html$ www.mysite.com/newpage [L,R=301]
# ... existing rewrites
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.