Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there any difference (subtle or otherwise) between the following rewrite conditions:

RewriteCond %{HTTP_HOST} ^www.mysite.co.uk$ 

and

RewriteCond %{HTTP:Host} ^www.mysite.co.uk$ 

In the second example I access the host name by specifying the HTTP header name: Host.

On the surface they both appear to behave exactly the same and if I turn up rewrite logging to 3 the log file shows identical activity.

Is %{HTTP_HOST} just a synonym for %{HTTP:Host}? For example, is %{HTTP_HOST} already populated/bound early whilst %{HTTP:Host} might incur a lookup penalty ?

share|improve this question

1 Answer 1

They are synonyms. See quotes from mod_rewrite documentation below:

About server variables like HTTP_HOST:

These variables all correspond to the similarly named HTTP MIME-headers,
C variables of the Apache server or struct tm fields of the Unix system.
Most are documented elsewhere in the Manual or in the CGI specification.

About HTTP:variable:

%{HTTP:header}, where header can be any HTTP MIME-header name, can always
be used to obtain the value of a header sent in the HTTP request.
share|improve this answer

Your Answer

 
discard

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.