Question

I have a folder called 'work' on my server that previously had .html files in it. Now all the files have .php extensions but clients still have the old links to the .html files. I don't want to redirect all .html files to .php versions from the root of the server, I only want this rule applied inside the 'work' folder.

From the root I would use:

RewriteRule ^(.*)\.html$ $1.php [L]

which worked fine. The problem is I now have the following rule applied for the root (used by wordpress for permalinks)

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

so it has broken any individual redirects I had set up. Previously I had set up each one individually using:

RewriteRule /work/index\.html /work/index\.php [RP]

So I would like to know if there is a way I could redirect all .html links inside the 'work' folder to .php versions using a one-for-all rule. Failing that, how would I set up the redirects individually?

EDIT: I'm using ISAPI rewrite on IIS

Était-ce utile?

La solution

Use this rule:

RewriteRule ^(work)/([^.]+)\.html$ /$1/$2.php [R,L,NC]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top