php - Too many redirects error -


my .htaccess file has 3 rewrite rules, i'm facing redirect issue:

rewriteengine on  rewritebase /  rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  rewritecond %{remote_addr} =ip block goes here rewritecond %{remote_addr} =another ip block goes here rewritecond %{request_uri} !^/blocked rewriterule ^(.*)$ http://www.myhost.com/blocked [r=307,l]  rewritecond %{remote_addr} !=authorized ip here rewritecond %{request_uri} !^/maintenance rewriterule ^(.*)$ http://www.myhost.com/maintenance [r=307,l]  errordocument 400 /400.php errordocument 401 /401.php errordocument 403 /403.php errordocument 404 /404.php errordocument 500 /500.php 

the problem if blocked ip tries access site when under maintenance, receive "incorrect redirect" error. how stop rewrite processing if ip 1 of denied ips?

you can use:

rewriteengine on  rewritebase /  rewritecond %{remote_addr} =ip block goes here rewritecond %{remote_addr} =another ip block goes here rewritecond %{request_uri} !^/blocked rewriterule ^ http://www.myhost.com/blocked [r=307,l]  rewritecond %{remote_addr} !=authorized ip here rewritecond %{request_uri} !^/(?:maintenance|blocked) rewriterule ^ http://www.myhost.com/maintenance [r=307,l]  rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  errordocument 400 /400.php errordocument 401 /401.php errordocument 403 /403.php errordocument 404 /404.php errordocument 500 /500.php 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -