I have a .htaccess that contains the following :
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(.*)/maintenance/(.*)$ [NC]
RewriteRule ^(.*).jpg$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).jpeg$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).gif$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).png$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).php$ /mysite/maintenance/maintenance.php [NC,R=302,L]
Tested on localhost.
With these settings, I have an infinite loop when trying to load http://localhost/mysite/test.php, (correctly) redirected to http://localhost/mysite/maintenance/maintenance.php
The loop seems to be due to the 4 image redirection (note : the maintenance page has a one an unique jpg background image located in the maintenance folder root). Commenting these 4 redirection lines solves the problem.
But I don't see why I enter in an infinite loop as the /maintenance/ path is itself excluded from redirection in the RewriteCond, and why the redirection on the images can interfere with this problem.
Can you help ?
You have to reorder your
RewriteConds
like this:RewriteCond
directive affects only the firstRewriteRule
after it.