php, $_SERVER & server_name

Igor Sysoev is at
Tue Sep 1 01:02:57 MSD 2009

On Mon, Aug 31, 2009 at 03:58:28PM -0500, AMP Admin wrote:

> I'm trying to list a bunch of domains under server_name.  I'm doing this
> because these domains generate dynamic content based on their name.  it
> seems to work fine except for one thing... $_SERVER['SERVER_NAME'] just
> displays the first server_name entry. 
> So say we have the following:
> server_name 	* * *;
> echo $_SERVER['SERVER_NAME']; displays * regardless which
> domain was entered into the browser. 

You need to change

-fastcgi_param  SERVER_NAME        $server_name;
+fastcgi_param  SERVER_NAME        $host;

in fastcgi_params.

Igor Sysoev

More information about the nginx mailing list