Forum Moderators: phranque
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME}!http://subdomain\.domain\.com/temp/index\.php
RewriteCond %{REMOTE_HOST}!888\.888\.888\.888
RewriteRule ^(.*)/?$ [subdomain\.domain\.com...] [R=301]
When I visit the site using my ip, it works fine. However if i change the ip so it would appear as if I were a normal user, I get an unending redirect.
Any help would be appreciated
Thanks
Or to be more correct: The value is always r->filename, but in per-server context r->filename has in its initial state the value of r->uri.
RewriteEngine on
# there is no need for a regEx here
RewriteCond %{REMOTE_HOST} !=888.888.888.888
# exclude the file directly in your rule-pattern
RewriteRule !^temp/index\.php$ http://subdomain.domain.com/temp/index.php [R=301,L] [edited by: Caterham at 5:09 pm (utc) on Sep. 2, 2006]
Be aware that if a port number is appended to the HTTP_HOST, this match will fail. I recommend using regex without an end anchor, or something like ^1\.1\.1\.1(:[0-9]{1,5})?$ or ^1\.1\.1\.1(:80)?$
Using string matching in RewriteCond is fine, but only when an exact match can be assured.
Jim
is appended to the HTTP_HOSTWe're matching against REMOTE_HOST here which does not contain any ports but the result of the reverse DNS lookup for REMOTE_ADDR. But anyway if the rev. lookup does not return a hostname, shouldn't REMOTE_HOST be empty at all (instead of copying the value of REMOTE_ADDR)?
So may be OP ment REMOTE_ADDR instead?
But if you wish to check the requesting client's IP address, REMOTE_ADDR is the correct variable to check. Checking REMOTE_HOST will invoke a reverse DNS lookup, and return a hostname if available, which won't match an IP address. Since an IP address is what we want to test here, the RNDS lookup for REMOTE_HOST won't work and wastes a lot of time.
Jim