Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I type

cat /etc/apache2/sites-enabled/*

I see

<VirtualHost *:80>
        ServerName myserver
        DocumentRoot /var/www/
</VirtualHost>
<VirtualHost *:80>
        ServerName www.mydomain1.net
        DocumentRoot /var/www/www.mydomain1.net/public/
</VirtualHost>

<VirtualHost *:80>
    ServerName mydomain1.net
    RedirectMatch permanent ^/(.*) http://www.mydomain1.net/$1
</VirtualHost>
<VirtualHost *:80>
        ServerName www.yasser.com
        DocumentRoot /var/www/www.mydomain2.com/public/
</VirtualHost>

<VirtualHost *:80>
    ServerName mydomain2.com
    RedirectMatch permanent ^/(.*) http://www.mydomain2.com/$1
</VirtualHost>

When I browse mydomain1.com and mydomain2.com, I see the contents from "myserver" which is list of directories in /var/www.

What am I doing wrong here?

Also here is the output of apachectl -S:

*:80                   is a NameVirtualHost
     default server myserver (/etc/apache2/sites-enabled/myserver:1)
     port 80 namevhost myserver (/etc/apache2/sites-enabled/myserver:1)
     port 80 namevhost www.mydomain1.net (/etc/apache2/sites-enabled/www.mydomain1.net:1)
     port 80 namevhost mydomain1.net (/etc/apache2/sites-enabled/www.mydomain1.net:6)
     port 80 namevhost www.mydomain2.com (/etc/apache2/sites-enabled/www.mydomain2.com:1)
     port 80 namevhost mydomain2.com (/etc/apache2/sites-enabled/www.mydomain2.com:6)
share|improve this question
    
Put your myserver at the end of the list. –  kobaltz Apr 19 '12 at 23:55

1 Answer 1

up vote 1 down vote accepted

First off, please use

Redirect permanent / http://www.example.org/

When doing a redirect of everything.

Also make sure that all your vhosts' ServerNames and ServerAliases are resolving correctly, both on the server and on the client.

Could you also post the output of

curl -Lv http://example.com/

here, so we can see what's going on, exactly?

share|improve this answer
    
The problem was that the server couldn't resolve the hostnames –  user893730 Apr 20 '12 at 1:46

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.