我想把两个域名解析到同一个209.221.156.243这个IP上,但是配置apache后 两个域名始终指向同一个站 
配置代码如下:
NameVirtualHost 209.221.156.243:80<VirtualHost 209.221.156.243:80>
    ServerName  xx.com
    DocumentRoot d:/aa
    ErrorDocument 404 /404.html
    ErrorLog  "|bin/rotatelogs.exe -l d:/aa/logs/errorlog.%Y-%m-%d-%H_%M_%S.log 86400" 
    CustomLog "|bin/rotatelogs.exe -l d:/aa/logs/access%Y-%m-%d.log 86400" combined
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^xx.com [NC]
    RewriteRule ^(.*)$ http://www.xx.com$1 [L,R=301]
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteRule .* - [F]
</VirtualHost>
<VirtualHost 209.221.156.243:80>
    ServerName  yy.com
    DocumentRoot d:/bb
    ErrorDocument 404 /404.html
    ErrorLog  "|bin/rotatelogs.exe -l d:/bb/logs/errorlog.%Y-%m-%d-%H_%M_%S.log 86400" 
    CustomLog "|bin/rotatelogs.exe -l d:/bb/logs/access%Y-%m-%d.log 86400" combined
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yy.com [NC]
    RewriteRule ^(.*)$ http://www.yy.com$1 [L,R=301]
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteRule .* - [F]</VirtualHost>
访问yy.com却访问到xx.com的程序!网上找了很多也没找到正解  望高手们帮看看

解决方案 »

  1.   

    并没有发现写法上的问题,我也是这么写的
    可能与 apache 的版本或其他设置有关
      

  2.   

    奇怪的是 我把第二个配置成www.yy.com后 
    当我去访问www.yy.com就能正确访问到bb下的程序
    但是不带www的yy.com 仍然访问的是aa下的程序也就是www.xx.com站!
      

  3.   

    我把第二个ServerName配置成www.yy.com后 
      

  4.   

    按规则 yy.com 是域,www.yy.com 才是域名
    或许有关系
    你可尝试注释掉全局的<Directory>一节
      

  5.   

    呃,单点进入 
    ServerName需要是域名
    加上你的RewriteRule是对www的,可能是这个原因