无法在 ServerName 中使用句点 [Lion Apache 安装]

无法在 ServerName 中使用句点 [Lion Apache 安装]

我可以像这样访问我的主机……

http://keggyshop

但不能使用句号……

http://keggyshop.dev

这是我的虚拟主机指令……

<VirtualHost *:80>
    ServerName keggyshop
    ServerAlias keggyshop.dev
    DocumentRoot "~/sites/2012/keggy/web/pages/keggy/120528/sandbox/public"

    <Directory "~/sites/2012/keggy/web/pages/keggy/120528/sandbox/public">
            Options Includes FollowSymLinks
            AllowOverride All
            Order allow,deny
    Allow from all

    </Directory>

</VirtualHost>

主机文件

127.0.0.1    keggyshop
127.0.0.1    keggyshop.dev


keggyshop 的跟踪路由…

user$ traceroute keggyshop
traceroute to keggyshop (192.168.1.184), 64 hops max, 52 byte packets
1  keggyshop (192.168.1.184)  1.188 ms  0.683 ms  0.747 ms


keggyshop.dev 的跟踪路由…

user$ traceroute keggyshop.dev
traceroute: Warning: keggyshop.dev has multiple addresses; using 184.106.15.239
traceroute to keggyshop.dev (184.106.15.239), 64 hops max, 52 byte packets
1  * 192.168.1.1 (192.168.1.1)  0.856 ms  0.568 ms
2  10.81.192.1 (10.81.192.1)  15.232 ms  7.002 ms  7.936 ms
3  gig-0-3-0-6-nycmnya-rtr2.nyc.rr.com (24.29.97.122)  7.962 ms  7.813 ms  7.712 ms
4  bun101.nycmnytg-rtr001.nyc.rr.com (184.152.112.107)  10.999 ms  14.001 ms  15.466 ms
5  bun6-nycmnytg-rtr002.nyc.rr.com (24.29.148.250)  11.231 ms  17.321 ms  12.745 ms
6  107.14.19.24 (107.14.19.24)  13.972 ms  11.704 ms  16.477 ms
7  ae-1-0.pr0.nyc30.tbone.rr.com (66.109.6.161)  9.237 ms  11.896 ms
   107.14.19.153 (107.14.19.153)  7.481 ms
8  xe-5-0-6.ar2.ewr1.us.nlayer.net (69.31.94.57)  16.682 ms  11.791 ms  11.981 ms
9  ae3-90g.cr1.ewr1.us.nlayer.net (69.31.94.117)  12.977 ms  15.706 ms  9.709 ms
10  xe-5-0-0.cr1.ord1.us.nlayer.net (69.22.142.74)  30.473 ms  30.497 ms  31.750 ms
11  ae1-20g.ar1.ord6.us.nlayer.net (69.31.110.250)  36.699 ms  50.785 ms  35.957 ms
12  as19994.xe-1-0-7.ar1.ord6.us.nlayer.net (69.31.110.242)  34.723 ms  31.118 ms  29.967 ms
13  coreb.ord1.rackspace.net (184.106.126.138)  30.471 ms
    corea.ord1.rackspace.net (184.106.126.136)  33.392 ms  35.210 ms
14  core1-coreb.ord1.rackspace.net (184.106.126.129)  32.453 ms
    core1-corea.ord1.rackspace.net (184.106.126.125)  32.020 ms
    core1-coreb.ord1.rackspace.net (184.106.126.129)  32.417 ms
15  core1-aggr401a-3.ord1.rackspace.net (173.203.0.157)  31.274 ms  34.854 ms  30.194 ms

答案1

在 DNS 名称中使用句点时需要小心。句点具有特殊含义,不应像其他字符一样处理。

无论如何,您需要确保您使用的名称可由您的客户端解析(最好通过 DNS 服务器)。您可以在本地环境中使用 hosts 文件进行测试。然后,您可以验证您的 Web 服务器配置是否与特定名称匹配。

答案2

你的问题在于你不理解。

更具体地说,当 .dev 解析为 127.0.0.1 以外的其他内容时,说明存在名称解析问题,而不是 vhost 问题。

您需要找出 keggyshop.dev 解析为多个地址的原因,并修复它,使其仅解析为 127.0.0.1

相关内容