我在 Windows 10 开发框中的 Apache/2.4.6 下启用了mod_status供我自己使用:
<Location /server-status>
SetHandler server-status
Require host localhost
Require host example
Require host example.com
Require ip 127.0.0.1
</Location>
(example
并example.com
代表我的 Windows Active Directory 主机名。)我还使用基于名称的虚拟主机,并且我有一个大致如下所示的默认主机:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Sites/Default/htdocs"
FallBackResource /index.php
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "C:/Sites/Default/htdocs">
Require all granted
AllowOverride All
Options -Indexes
</Directory>
</VirtualHost>
...并且工作正常:任何未明确配置的主机名或 IP 地址都会显示我的 PHP 驱动的站点不存在错误页面,包括http://localhost/
.
我可以通过任何托管站点或通过 IP 地址成功访问服务器信息:
http://some.other.site.example.org/server-status
http://127.0.0.1/server-status
但是,使用localhost
主机名会触发 403 Forbidden 状态代码:
http://localhost/server-status
AH01753: access check of 'localhost' to /server-status failed, reason: unable to get the remote host name
AH01753: access check of 'example' to /server-status failed, reason: unable to get the remote host name
AH01753: access check of 'example.com' to /server-status failed, reason: unable to get the remote host name
AH01630: client denied by server configuration: C:/Sites/Default/htdocs/server-status
我已经尝试localhost
从ServerName
我的默认虚拟主机的指令中删除,但我仍然得到Forbidden。
是什么导致localhost
异常?
localhost
正在解析为 IPv6 地址,因此我需要添加以下内容: