Where is third level of domain gone

Hello,

I am using Nginx 0.7.54 with php 5.2.8 as the web server. When I
configure
the host name, like: *.music.goog.com, I find a very wield phenonmenon
that
I can’t get the third level of this domain.

I print this variable in php:
$_SERVER[‘SERVER_NAME’] ; it says: music.goog.com

my nginx.conf follows like:
server
{
listen 80;
server_name music.goog.com *.music.goog.com;
index index.html index.htm index.php;

}

The requirement is I wanna get the third level of domain which is the
short
code of countries, (ex: ar, br, cn, us) to set the cookies then redirect
to
the concerned page. My idea is to redirect in the php page. I try to use
url
parameters with “?country=us” to implement. It’s ok but it’s no use when
users only input “http://ar.music.goog.com” or to show confusing result
with
http://ar.music.goog.com/?country=us

Hoping the experts reply.

Hello!

On Wed, Jun 17, 2009 at 03:33:52PM +0800, fei dong wrote:

Hello,

I am using Nginx 0.7.54 with php 5.2.8 as the web server. When I configure
the host name, like: *.music.goog.com, I find a very wield phenonmenon that
I can’t get the third level of this domain.

I print this variable in php:
$_SERVER[‘SERVER_NAME’] ; it says: music.goog.com

SERVER_NAME is server’s name, not Host header from client request.
Use HTTP_HOST instead.

Maxim D.

On Wed, Jun 17, 2009 at 12:58:07PM +0400, Maxim D. wrote:

I print this variable in php:
$_SERVER[‘SERVER_NAME’] ; it says: music.goog.com

SERVER_NAME is server’s name, not Host header from client request.
Use HTTP_HOST instead.

If he uses fastcgi, then he may use

  • fastcgi_param SERVER_NAME $server_name;
  • fastcgi_param SERVER_NAME $host;

You are right, Thanks!