Basically I\'m about to start work on a site and I\'d like something that I can add into my .htaccess file (or elsewhere) that\'ll work like this pseudo code: (my ip will be in
That would be something like:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{REQUEST_URI} !/mypage\.html$
RewriteRule .* http://www.anothersite.com/mypage.html [R=302,L]
As Andrew points out, the %{REQUEST_URI} condition avoids infinite loop if you redirect to the same domain.
As Xorax comments almost 9 years later:
You should not use
REMOTE_HOST
, it will fail in many case. You should useREMOTE_ADDR
.
Cf "difference between REMOTE_HOST and REMOTE_ADDR"