Shambhala
Shambhala

Reputation: 1169

htaccess RewriteRule causing Error 310 (ERR_TOO_MANY_REDIRECTS)

First I will explain what I am trying to accomplish. I want to only allow access to my website with my own IP Address while I am developing and everyone else will be directed to my offline.html

My website is running on Joomla! 2.5.9

I have added this .htaccess file to the root directory:

I have replaced my IP address with 123.123.123.123 just for putting on here. My IP Address is static.

RewriteEngine On

RewriteCond %{REMOTE_HOST}        !^123\.123\.123\.123$
RewriteCond %{REQUEST_URI}        !^offline\.html
RewriteCond %{REQUEST_URI}        !^(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.swf|\.css|\.js)$
RewriteRule ^(.*)                /offline.html    [R=307,L]

When I test going to my site through my VPN I will get the below Error message from Chrome:

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

After that I see the correct path to offline.html has been added and the same with Firefox although the Error Message is slightly different:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

What could be the cause of this?

Upvotes: 1

Views: 1686

Answers (1)

Felipe Alameda A
Felipe Alameda A

Reputation: 11799

You may try this:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR}  !123\.123\.123\.123
RewriteCond %{REQUEST_URI}  !\.(png|jpg|gif|jpeg|bmp|swf|css|js)  [NC]
RewriteCond %{REQUEST_URI}  !offline\.html
RewriteRule  .*              offline.html                     [R=307,L]

Upvotes: 1

Related Questions