.htaccess - move the site from .html to .php, but exclude the folder

I have a new site and an old version of the site in the old folder.

The new site has the same page names as the old one, except that everyone now has the .php extension.

I have the following rule for SEO to direct all .html files to .php

RedirectMatch 301 (.*)\.html$ http://www.mysite.com$1.php

But I still need to have access to everything in the / old folder - the redirect explicitly redirects the files here (for example, mysite.com/old/mypage.html is sent to mysite.com/old/mypage.php - I need the .html version)

I tried to find out for myself, but I'm not sure about all the RedirectXYZ commands.

Any ideas?

+3
source share
1 answer

You can achieve this by using a negative view :

RedirectMatch 301 ^(?!/old)(.*)\.html$ http://www.mysite.com$1.php

(?!/old) , /old . ^, .

+1

Source: https://habr.com/ru/post/1782908/


All Articles