pierzakp
pierzakp

Reputation: 81

subdomain virtual host show wrong directory

I have problem with subdomain virtual host, it's pointing to my /var/www instead of /var/www/info.

I have domain, let's it be xyz.com, created dynhost to this domain, and subdomain cname to this domain, so if i ping both of them i have the same IP address.

I created two virtual hosts: xyz.com and info.xyz.com, so i have 2 files in /etc/apache2/sites-avaible, and 2 symlinks to those files in /etc/apache2/sites-enabled.

xyz.com virtual host:

<VirtualHost *:80>
    DocumentRoot /var/www
    ServerName xyz.com
    ServerAlias xyz.com *.xyz.com

    ErrorLog /var/log/apache2/xyz.com-error.log
    TransferLog /var/log/apache2/xyz.com-access.log

    <Directory /var/www>
            Options -Indexes +FollowSymLinks
            AllowOverride All
            Order deny,allow
            Allow from all
    </Directory>
</VirtualHost>

info.xyz.com

<VirtualHost *:80>
    DocumentRoot /var/www/info
    ServerName info.xyz.com
    ServerAlias info.xyz.com *.info.xyz.com

    ErrorLog /var/log/apache2/info.xyz.com-error.log
    TransferLog /var/log/apache2/info.xyz.com-access.log

    <Directory /var/www/info/>
            Options -Indexes +FollowSymLinks
            AllowOverride All
            Order deny,allow
            Allow from all
    </Directory>
</VirtualHost>

My OS is ubuntu server 12.04.

Can somebody help?

Upvotes: 0

Views: 1297

Answers (1)

Tony
Tony

Reputation: 751

Your alias:

ServerAlias xyz.com *.xyz.com

Is catching requests for both sites since you have a wildcard.

Upvotes: 1

Related Questions