2016-01-05 17:32:36 7294次浏览 2条回答 0 悬赏 10 金钱

我配置了三个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>

最佳答案

  • 发布于 2016-01-06 11:11 举报

    Apache中没有捕获到的主机名,默认使用第一个虚拟主机。

    觉得很赞
  • 回答于 2016-01-05 17:42 举报

    问题描述不明不白..
    确认你的配置已生效,
    确定各端口都正常访问,
    再确认没有别的规则指向www目录

    3 条回复
    回复于 2016-01-05 17:59 回复

    配置已经生效了。
    但是当我回头想用localhost访问www后直接跳转到basic/web了。

    回复于 2016-01-05 20:04 回复

    ==,你是要访问www目录? 你不是指向了basic/web吗?跳到web目录不应该是理所当然吗?

    回复于 2016-01-05 21:56 回复

    有道理。。。我再指定localhost指向www不就可以了???
    原来坎在这里。。

您需要登录后才可以回答。登录 | 立即注册
qiliux
助理

qiliux

注册时间:2015-07-27
最后登录:2016-01-26
在线时长:2小时22分
  • 粉丝1
  • 金钱94
  • 威望0
  • 积分114

热门问题