简体   繁体   English

Apache vhost总是在不同的子域上向我显示相同的内容

[英]Apache vhost always show me the same content on different subdomains

I have two subdomains on my VPS, i have registered the two subdomains in my DNS pointing to the same IP address. 我的VPS上有两个子域,我已经在DNS中注册了指向相同IP地址的两个子域。

the version installed is Server version: Apache/2.4.7 for Ubuntu 12.04. 安装的版本是服务器版本:适用于Ubuntu 12.04的Apache / 2.4.7。

I've enabled the sites with the a2ensite command and i have enable the module vhost_alias . 我已经使用a2ensite命令启用了站点,并且启用了模块vhost_alias restart and reloaded many times 重新启动并重新加载多次

stable.mydomain.com

<VirtualHost *:80>        
    ServerName stable.mydomain.com

    DocumentRoot /var/www/stable/web

    <Directory /var/www/stable/web>
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

beta.mydomain.com

<VirtualHost *:80>

    ServerName beta.mydomain.com

    DocumentRoot /var/www/beta/web

    <Directory /var/www/beta/web>
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

my trouble is pointing my browser to any url always i get the same content and to add more confusion when i execute service apache2 reload in the two subdomains i get the content from beta.mydomain.com and when execute service apache2 restart in the two subdomains i get the content of stable.mydomain.com . 我的麻烦是始终将我的浏览器指向任何url,当我在两个子域中执行service apache2 reload ,我会从beta.mydomain.com获取内容;当我在两个子域中执行service apache2 restart时,我总是会得到相同的内容,并增加更多的混乱我得到了stable.mydomain.com的内容。

I have spent about 5 hours trying to fix this 我花了大约5个小时来解决这个问题

update 更新

event i try with the VirtualDocumentRoot 如果我尝试使用VirtualDocumentRoot

<Virtualhost *:80>
    VirtualDocumentRoot "/var/www/%1/web"
    ServerName stable.mydomain.com
    ServerAlias *.mydomain.com
    UseCanonicalName Off
    <Directory "/var/www/*">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</Virtualhost>

with the same behavior explained before this update 具有与此更新之前说明的相同行为

在定义虚拟主机之前,您是否已取消注释此行?

NameVirtualHost *:80

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM