wamp子域别名奇怪的行为

时间:2013-01-21 06:36:41

标签: php mod-rewrite localhost wamp alias

我在Windows 7上使用WAMP

已经创建了zf2-tutorial.localhost的别名,已将其添加到驱动程序/ etc / hosts中 还启用了虚拟主机设置:

Include conf/extra/httpd-vhosts.conf

根据此

在此文件中设置了我的别名
<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

当我打开zf2-tutorial.localhost时,它会按预期显示zend页面。但是,当我尝试打开localhost页面时,它会显示:

Forbidden

You don't have permission to access / on this server.

在httpd.conf中禁用虚拟主机,允许打开localhost但无法打开zf2-tutorial.localhost

1 个答案:

答案 0 :(得分:2)

可能重复here

为了能够在启用虚拟主机的同时访问localhost,httpd-vhosts.conf中的第一个条目需要命名为localhost并链接到您的Web根目录。

<VirtualHost *:80>
     ServerName localhost
     DocumentRoot "path/to/your/www/folder"
</VirtualHost>
<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

请参阅Setup Apache to serve multiple sites的第3步中的示例。

相关问题