ServerAlias不起作用

时间:2014-04-28 14:48:26

标签: apache vhosts

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没有...

2 个答案:

答案 0 :(得分:0)

只需将其写在一行:

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

答案 1 :(得分:0)

您似乎已经将example.com用于主网站,即您拥有:

ServerName example.com

<VirtualHost>个容器。当有几个匹配时,Apache将只检索第一个匹配。