Subdomain always redirects to main domain. Why?

6,853

Those wacky configs from /var/www/vhosts/ (looks like they're from Plesk?) are using the full IP as their vhost address declaration, so the *:80 listener won't ever get any requests to that IP. Assuming that you only have that one IP on your server, this isn't desired.

Change the <VirtualHost> line in your newly created host, to have it be used for requests that hit the Plesk-created name-based vhost:

<VirtualHost 83.169.46.168:80>
    ServerName site1.example.com
    DocumentRoot "/var/www/vhosts/example/site1"
    <Directory /var/www/vhosts/example/site1>
        Allow from all
        AllowOverride All
    </Directory>
</VirtualHost>
Share:
6,853
UpCat
Author by

UpCat

Updated on September 18, 2022

Comments

  • UpCat
    UpCat almost 2 years

    when I request site1.example.com I get redirected to example.com. In /etc/apache2/sites-available/ I have setup a site1.example.de file with following content

    <VirtualHost *:80>
        ServerName site1.example.com
        DocumentRoot "/var/www/vhosts/example/site1"
            <Directory /var/www/vhosts/example/site1>
              Allow from all
              AllowOverride All
            </Directory>
    </VirtualHost>
    

    After

    sudo a2ensite site1.example.com
    

    and reloading apache it still redirects me to main domain. Any ideas why?

    I use apache2/2.2.14 (Ubuntu 10.4). My server is acting as nameserver.

    • ravi yarlagadda
      ravi yarlagadda about 12 years
      Does the address displayed in your browser change, or does it stay the same and just send you the content from the main site?
    • UpCat
      UpCat about 12 years
      the url stays the same but displays the content from the main page
    • ravi yarlagadda
      ravi yarlagadda about 12 years
      Looks like your new vhost file isn't taking effect - I wonder if your main vhost isn't using the same host/port combination (*:80)? Can you provide the output from apache2ctl -S?