Home .htaccess Redirecting Too Many Times Using Get Variables

# .htaccess Redirecting Too Many Times Using Get Variables

Jesse Elser
1#
Jesse Elser Published in 2017-11-14 17:46:36Z
 I'm trying to redirect users from my main index page back to the index page but with a variable in the url to swap the loaded files. What I'm getting is too many redirects since I've added variables. Here is what I've done:  RewriteCond %{TIME} <20171201000000 RewriteCond %{REMOTE_ADDR} !^00\.000\.000\.000 RewriteCond %{REQUEST_FILENAME} !(styles|images|javascript).+$RewriteCond %{REQUEST_URI} !construction.php$ [NC] RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|ttf|woff|js) [NC] RewriteRule .* /construction [R=302,L]  This part works fine and redirects. However I've added a case switch function to my index page to eliminate the construction.php page altogether. So now I've made my redirect into this and it's redirecting too much.  RewriteCond %{TIME} <20171201000000 RewriteCond %{REMOTE_ADDR} !^00\.000\.000\.000 RewriteCond %{REQUEST_FILENAME} !(styles|images|javascript).+$RewriteCond %{REQUEST_URI} !index.php?redirect=construction$ [NC] RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|ttf|woff|js) [NC] RewriteRule .* /index.php?redirect=construction [R=302,L]  The reason I am doing this is because I am going to have several redirects from construction to maintenance, 404, etc. What would cause this to keep redirecting too much when all I did was change the urls? Just for reference here is the entire index.php file: 

Croises
2#
 You can't do that: RewriteCond %{REQUEST_URI} !index.php?redirect=construction$[NC]  Because query string is not part of the test uri. Use instead: RewriteCond %{REQUEST_URI} !index\.php$ [NC,OR] RewriteCond %{QUERY_STRING} !redirect=(?:construction|404)\$ [NC]  You can omit the first line, If you use redirect=construction only for this page.