I've got a new site, and put the old version of the site in an /old folder.
The new site has the same page names as the old one, except they all now have a .php extension.
I've got the following rule for SEO to direct all the .html files to .php
RedirectMatch 301 (.*)\.html$ http://www.mysite.com$1.php
But I still need to be able to access everything in the /old folder - the redirect is obviously redirecting the files in here too (e.g. mysite.com/old/mypage.html is going to mysite.com/old/mypage.php - I need the .html version)
I've tried to find out for myself, but I'm not sure about all the RedirectXYZ commands.
Any ideas?
You can achieve this using negative lookahead:
RedirectMatch 301 ^(?!/old)(.*)\.html$ http://www.mysite.com$1.php
(?!/old) rejects a match containing the string /old at this position. We use ^ to restrict this to the beginning of the string being matched against.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With