【问题标题】:ServerAlias does not work服务器别名不起作用
【发布时间】:2014-04-28 14:48:26
【问题描述】:

Apache/2.2.22 (Ubuntu)

<VirtualHost *:80>
  ServerName    www.example.com      # Works
  ServerAlias   new.example.com      # Works
  ServerAlias   example.com          # Does not work - shows apache default "It works"
  DocumentRoot  /usr/share/drupal7   # /tmp shows the same behavior
</VirtualHost>

所有域的 ip 相同(ping new.example.com = ping www.example.com = ping example.com)

编辑:

任何顶级域的行为都是这样... www.test.com 有效 - test.com 不...

【问题讨论】:

  • 更多信息会有所帮助
  • 您是否 100% 确定在其他之前的指令(例如主站点)中没有另一个 example.com 条目?
  • 请勿编辑并放置 RESOLVED。添加答案并接受您的答案。这是适当的约定
  • 此外,您关于 IP 解析的陈述与问题中的信息相矛盾。
  • ping 服务器和 apache 服务器不同

标签: apache vhosts


【解决方案1】:

您似乎已经将example.com 用于主站点,也就是说,您有这个:

ServerName example.com

&lt;VirtualHost&gt; 容器之外。当有多个匹配项时,Apache 将简单地检索第一个。

【讨论】:

    【解决方案2】:

    只写一行:

    <VirtualHost *:80>
        ServerName    www.example.com 
        ServerAlias   new.example.com *.example.com
        DocumentRoot  /usr/share/drupal7
    </VirtualHost>
    

    【讨论】:

    • 仍然没有效果。 xxx.com - 无论放在哪里都不起作用(ServerName 或 ServerAlias)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    • 2013-04-19
    相关资源
    最近更新 更多