谁一开始就是大神?

apache配置virtualHost后。localhost无法访问www目录[2.0]

我配置了三个virtualHost.
使用这三个vituralHost可以访问相应的应用 。现在下面三个的配置已经生效。

但是我现在想用localhost访问 www目录时,却直接被转到basic/web。换句话说就是直接显示basic应用的内容了。

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "D:/wamp/www/basic/web"
    <Directory "D:/wamp/www/basic/web">
        RewriteEngine on
        Allow from all
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php
    </Directory>
    ServerName www.yii2.com
    ServerAlias www.yii2.com
    ErrorLog "logs/yii2.com-error.log"
    CustomLog "logs/yii2.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "D:/wamp/www/yiiadv/frontend/web"
    <Directory "D:/wamp/www/yiiadv/frontend/web">
        RewriteEngine on
        Allow from all
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php
    </Directory>
    ServerName www.yiiadv.com
    ServerAlias www.yiiadv.com
    ErrorLog "logs/yiiadv.com-error.log"
    CustomLog "logs/yiiadv.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "D:/wamp/www/yiiadv/backend/web"
    <Directory "D:/wamp/www/yiiadv/backend/web">
        RewriteEngine on
        Allow from all
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php
    </Directory>
    ServerName www.backend.yiiadv.com
    ErrorLog "logs/yiiadv.com-error.log"
    CustomLog "logs/yiiadv.com-access.log" common
</VirtualHost>

Apache中没有捕获到的主机名,默认使用第一个虚拟主机。
问题描述不明不白..
确认你的配置已生效,
确定各端口都正常访问,
再确认没有别的规则指向www目录

赞(0) 打赏
未经允许不得转载:菜鸟之家 » apache配置virtualHost后。localhost无法访问www目录[2.0]

评论 抢沙发

登录

找回密码

注册