0

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?

elixenide
  • 44,308
  • 16
  • 74
  • 100
Ragagno
  • 53
  • 1
  • 5

1 Answers1

3

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:

Community
  • 1
  • 1