Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Does the address displayed in your browser change, or does it stay the same and just send you the content from the main site? –  Shane Madden May 15 '12 at 22:09
    
the url stays the same but displays the content from the main page –  ArtWorkAD May 16 '12 at 19:14
    
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? –  Shane Madden May 16 '12 at 19:16

2 Answers 2

up vote 3 down vote accepted

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|improve this answer

Look at the Apache error logs for entries trying to get to the sub-domain. Most of the time I've had this issue Apache could not find the directory on the server (or file permission issues).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.