[英]WAMP virtual host contains no domain
I'm using WAMP, with a virtual host. 我正在将WAMP与虚拟主机一起使用。 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. 是的,
REQUEST_URI
不应该包含主机,仅包含主机之后和查询字符串之前的部分。 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). HTTP_HOST
是在请求标头(正在访问的实际主机)中指定的HTTP_HOST
。 SERVER_NAME
is the one that is set up as the ServerName
on the virtual host. SERVER_NAME
是在虚拟主机上设置为ServerName
。 Not always the same as each other if coming in on a ServerAlias
. 如果进入
ServerAlias
,则彼此并不总是相同的。
References: 参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.