htaccess on apache
I have this url:
mydomain.com/old.html
I want it to be rewritten as:
mydomain.com/new.html
But I also want mydomain.com/old.html to always redirect to mydomain.com/new.html.
I tried the following:
RewriteRule ^/new.html /old.html [R=301,L,PT]
But it doesn’t work.
Remove the leading slash (or make it optional) because it’s stripped from URI’s when applying rules in an htaccess file:
This would be required to work in conjunction with other rewrite rules, so that everything happens within one module (mod_rewrite), but if you do not need mod_rewrite, you can rely on mod_alias instead (removing the mod_rewrite redirect):
But this will redirect stuff like:
/old.html/blahblahtohttp://www.yoursite.com/new.html/blahblahIf you don’t want that, use: