Ragagno
Ragagno

Reputation: 53

WAMP virtual host contains no domain

I'm using WAMP, with a virtual host. The problem is that when I'm on my virtual host,

$_SERVER['REQUEST_URI']

contains only a "/" when I'm on the index; it doesn't contain the domain name. Why?

Upvotes: 0

Views: 124

Answers (1)

user2493235
user2493235

Reputation:

Yes, the REQUEST_URI is not supposed to contain the host, only the part after the host and before the query string. Use:

$_SERVER['HTTP_HOST']

Or:

$_SERVER['SERVER_NAME']

HTTP_HOST is the one that was specified in the request header (the actual host being visited). SERVER_NAME is the one that is set up as the ServerName on the virtual host. Not always the same as each other if coming in on a ServerAlias.

References:

Upvotes: 3

Related Questions