Sorry for the long title. I’m currently writing some 301 redirects and using mod rewrite (Apache) to handle them. Currently only one of the two 301s I have tried is working. Here is the code:
#301 REDIRECTS
RewriteEngine On
RewriteRule ^Fox-and-Frank-home\.html$ http://www.mydomain.co.uk/contact_us.php [R=301]
RewriteRule ^about\.html$ http://www.domain.com/about/ [R=301,L]
about.html properly redirects, but Fox-and-Frank-home.html does not. I have tried this with other names, other URLs, but it is not working. Any help will be greatly appreciated.
EDIT
I have gotten this to work on a completely bare .htaccess file. Do 301 redirects need to be at the very top before everything else?
You don’t have a L (last) flag on your Fox-and-Frank rewrite, so other rules can potentially be processed, and definetly will be in a
.htaccess(where you need to use theENDflag).Try changing it to:
Where:
redirect to)
and 301 would be assumed I always specify it personally)
mod_rewrite to stop processing further rules (but as its in a
.htaccess.you may need to useENDinstead – see http://httpd.apache.org/docs/current/rewrite/flags.html#flag_l).Regards.