Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to match a referer to a host name in my .htaccess and stumbled upon the following.

The condition reads:

RewriteCond %{HTTP_REFERER} ^https://%{HTTP_HOST}.*$

But this never matches, and the log file for mod_rewrite states this:

RewriteCond: input='' pattern='^https://%{HTTP_HOST}.*$' => not-matched

Why is the HTTP_HOST variable not getting expanded in this condition?

share|improve this question
up vote 1 down vote accepted

This is expected behavior. See here and here for details / workarounds.

share|improve this answer
So it appears there is no way to work around my particular issue, where I want to substitute host name into the comparison? – SaltyNuts Jul 26 '12 at 15:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.