ReWrite rule doesn’t work for urls containing underscores
-
Hope somebody can figure this one out. I have the following code for a WordPress static export site in my .htaccess file which redirects any request ending in .html to /index.html e.g. /subdirectory/pageexists.html gets redirected to /subdirectory/pageexists/index.html THAT works fine. BUT... if the requested file with the .html includes an underscore I get a "too many redirects" error. e.g. /subdirectory/page_exists.html tries to connect /subdirectory/subdirectory/subdirectory/page_exists/index/index/index.html # Enable Rewrite module RewriteEngine on RewriteRule ^ - [E=rewrite:on] # Check if requested file or directory already exists RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !index\.html$ # Redirect all .html file requests to equivalent /index.html file request RewriteRule ^(.*)\.html$ /subdirectory/$1/index.html [R=301,L] # If the Rewrite module is not active then return a 404 error RewriteCond %{ENV:rewrite} !on RewriteRule ^ - [L,R=404]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘ReWrite rule doesn’t work for urls containing underscores’ is closed to new replies.