#205 $server_name != $http_host

Installation
closed
Reini Urban
PHP 4.1 (9)
5
2012-10-11
2003-08-14
Hans Schou
No

Hi

I got a site at an ISP which can be accessed in several
ways, either
by www.aaa.org or www.bbb.org .

In Apache the site SERVER_NAME is currently set to
www.aaa.org but I do not yet have that domain, it will
be bought later.

To test the site I got another domain, a long one from
my ISP with customer number and so on - lets call it
www.bbb.org

When I access http://www.bbb.org/
$HTTP_SERVER_VARS['SERVER_NAME'] is still equal to
www.aaa.org and then I can only load the first page
from the server and no graphics.

I solved the problem by adding this line to index.php
if (!defined('SERVER_NAME')) define('SERVER_NAME',
$HTTP_SERVER_VARS['HTTP_HOST']);

In that way the server name is equal to what the user
typed in and not what the server think is the name.

I guess that it might be better to change
lib/config.php but someone here might have a better idea.

Discussion

  • Reini Urban
    Reini Urban
    2004-04-18

    Logged In: YES
    user_id=13755

    we won't support that. You are on your own here. BTW: this
    is RFE not a bug.

    solve that by fooling your /etc/hosts file and a vhost in
    your setup.