0

我的httpd-vhosts.conf文件配置如下:

<VirtualHost seg.localhost:81>
    ServerAdmin my@email.com
    DocumentRoot "D:\path\to\public_html"
    ServerName http://seg.localhost
    ServerAlias http://seg.localhost
    ErrorLog "logs/seg.log"
    CustomLog "logs/seg" common
    <directory "D:\path\to\public_html">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from all
    </directory>
</VirtualHost>

但是当我进入http://localhost:81/我的浏览器时,它仍然在点击那个文件夹。为什么子域被忽略?

4

1 回答 1

2

如果您使用基于名称的虚拟主机,最顶层的虚拟主机(<VirtualHost>块的第一个实例)被认为是“默认”<VirtualHost>虚拟主机,这意味着如果请求的主机与任何给定的 's不匹配,使用最上面的那个。

您可以通过添加一个简单地拒绝所有内容的新顶级虚拟主机来解决此问题:

<VirtualHost seg.localhost:81>
   ServerName _default_
   DocumentRoot "D:\path\to\public_html"
   <Directory "D:\path\to\public_html">
      Order Allow,Deny
      Deny from all
   </Directory>
</VirtualHost>

或者让它重定向到 seg.localhost,或者你想处理它。

于 2012-09-12T06:13:16.483 回答