RewriteCond to determine if host name or IP address is being accessed in Apache?

Frank Tsao
Frank Tsao used Ask the Experts™
on
Hi experts,

How can I set up a RewriteCond to check if someone is accessing a site by its hostname (e.g. mydomain.com) or by the IP address (e.g. 123.4.5.6)?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
Hi

By adding a RewriteCond e.g.

RewriteCond %{HTTP_HOST}   192.168.0.111
RewriteRules xxxxxxx  zzzzzzzzzz [R=301,L]

RewriteCond %{HTTP_HOST}   www\.somehost\.com
RewriteRules xxxxxxx  yyyyyyyyy   [R=301,L]
Thanks :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial