WAMP虚拟主机不包含域

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?

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: