Consider the following rules
RewriteRule ^index\.html$ index.php [L]
RewriteRule ^index\.php$ index.html [R=301]
I want .html to use the .php file, but I want the url to have the .html extension always.
The above rule creates a redirection loop. What’s the right way to do this?
You can either check against the actual request, or prevent looping entirely.
Option 1, check against request:
This makes it so if the actual request isn’t
index.php, the redirect won’t happen.Option 2, prevent rewrite engine from looping entirely. Add this to the top of your htaccess file:
The downside with this is that you may have rules that actually want to loop.