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

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

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

Watch Question

Do more with

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

By adding a RewriteCond e.g.

RewriteCond %{HTTP_HOST}
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