Question

I would like to change the rewrite rule to only apply to the current folder that the htaccess file is in

RewriteEngine on
RewriteRule ^(.*)\.html $1\.php 

how do I change this to make that work? Thanks,

Was it helpful?

Solution

Restrict your pattern to only match characters other than /:

RewriteRule ^([^/]+)\.html$ $1.php

OTHER TIPS

If you have a limited number of known sub-directories I would do something like this:

RewriteCond %{REQUEST_URI} (list|of|sub|dirs)
RewriteRule . - [s=1]
RewriteRule ^(.*)\.html $1\.php

That skips the next 1 rule when the condition is true. You could change the [s=1] to match any number of rules you want to not apply to the sub-directories.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top