Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Apache/Mod_Rewrite: Redirect and Rewrite without Loop

I want to redirect all pages that have ".html" as the extension to NOT have the ".html" extension and I want to rewrite all pages that do NOT have an extension to point to the page with the ".html" extension.  The problem is that my code creates a loop so does not work.

How can I get this to work without creating a loop?

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_fileNAME} -f
RewriteRule ^(.*)\.html$ $1 [L,R=301]

RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
rewriterule ^(([^/]+/)*[^./]+)/?$ /$1.html [L]
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial