[development] Loading configuration using 'SERVER_NAME' as opposed to 'HTTP_HOST'

Earnie Boyd earnie at users.sourceforge.net
Mon Mar 16 19:48:08 UTC 2009

Quoting Adam Cooper <adam.j.cooper at gmail.com>:

>> This is more a support question and should be on the support list  
>> but see below.
> Granted this is could be a support issue, but I had intended to  
> (mostly) gauge the validity of a patch to core. Is that not a  
> development question?

These types of questions are presented more as a feature request in an 
issue queue.

>> My question back to you is why isn't HTTP_HOST properly setup?
> AFAICT it is functioning exactly as designed. It returns the value of 
>  the Host: header as sent by the client. Numerous experiments with  
> phpinfo() have confirmed that.
> According to the apache docs (and confirmed by the above mentioned  
> experiments) if UseCanonicalName is set to 'off' the SERVER_NAME  
> variable is set to equal HTTP_HOST. This works great in most all  
> cases. If UseCanonicalName is set to 'on' then SERVER_NAME is set to  
> whatever 'ServerName' is set to in the apache conf. Seeing as  
> UseCanonicalName can be set in the virtual host entry there is no  
> problem doing something like this:
> <VirtualHost *:80>
> 	UseCanonicalName On
> 	ServerName hostname.com
> 	ServerAlias hostname.dev
> </VirtualHost>

Based on the http://drupal.org/node/262920 issue sited below changing to

<VirtualHost *:80>
	UseCanonicalName Off

	ServerName hostname.dev
	ServerAlias hostname.com

Should work for you.

> If Drupal used the SERVER_NAME variable then accessing the site 
> should  load the hostname.com configuration regardless of what alias 
> is  accessed. Seeing as it uses HTTP_HOST it will fail to load a  
> configuration.

I don't dislike your proposal maybe a combination of the two would be a 
good solution with HTTP_HOST being used first.  Work up a patch for D7 
and see where it goes.

Earnie  http://r-feed.com
  Make a Drupal difference and review core patches.

-- http://for-my-kids.com/  -- http://www.4offer.biz/

More information about the development mailing list