Apache serves only the default virtualhost, ubuntu

0

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)

user893730

Posted 2012-04-19T23:53:07.347

Reputation: 1 097

Put your myserver at the end of the list. – kobaltz – 2012-04-19T23:55:00.733

Answers

1

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?

Igor Galić

Posted 2012-04-19T23:53:07.347

Reputation: 36

The problem was that the server couldn't resolve the hostnames – user893730 – 2012-04-20T01:46:33.437