Apache2 name based virtual host always redirect 301
- by Francesco
I've got a server (runnging Debian Squeeze) with Apache 2.2, there are 4 site running there.
I'm using namebased virtulhosts because I've got a single IP. Initial configuration has been made with Webmin and probably something has been messed up..
firstdomain.com is my default domain and is working correctly, seconddomain.com is another site that is working. Now I want to add lastdomain.tk as a new site, so I've made this config file:
root@webamp:/etc/apache2# cat sites-available/lastdomain.tk.conf
<VirtualHost *:80>
DocumentRoot /home/server/Condivisione/RAID/lastdomain.tk
ServerName www.alazanes.tk
ServerAlias alazanes.tk
</VirtualHost>
I've added it to enabled-sites and restarted apache.
The problem is that if I go to lastdomain.tk (or www.lastdomain.tk) I'm redirected to firstdomain.com with a 301 redirect.
Both lastdomain.tk and www.lastdomain.tk are A DNS records pointing to my IP address.
Strange thing is that if a change DocumentRoot of lastdomain.tk to
DocumentRoot /home/server/Condivisione/RAID/Sito_SecondDomain
I correctly see seconddomain.com content without being redirected (lastdomain.tk is showed on address bar)
These are the other configurations I'm using.
root@webamp:/root# source /etc/apache2/envvars ; /usr/sbin/apache2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 webamp.firstdomain.com (/etc/apache2/sites-enabled/ssl.bbteam:1)
*:80 is a NameVirtualHost
default server firstdomain.com (/etc/apache2/sites-enabled/000-default:7)
port 80 namevhost firstdomain.com (/etc/apache2/sites-enabled/000-default:7)
port 80 namevhost www.lastdomain.tk (/etc/apache2/sites-enabled/lastdomain.tk.conf:1)
## other domains ##
port 80 namevhost seconddomain.com (/etc/apache2/sites-enabled/seconddomain.com.conf:1)
Syntax OK
Content of default config file is
root@webamp:/etc/apache2# cat sites-available/default
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName firstdomain.com
ServerAlias www.firstdomain.com direct.firstdomain.com
DocumentRoot /home/server/Condivisione/RAID/Sito_Web_Apache_su_80
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
content of second domain config file is
root@webamp:/etc/apache2# cat sites-available/seconddomain.com.conf
<VirtualHost *:80>
DocumentRoot /home/server/Condivisione/RAID/Sito_SecondDomain
ServerName seconddomain.com
ServerAlias www.seconddomain.com direct.seconddomain.com
#redirect 301 / http://www.seconddomain.com/
<Directory "/home/server/Condivisione/RAID/Sito_SecondDomain">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Probably a file permission problem?
root@webamp:/root# ls -lh /home/server/Condivisione/RAID/
total 7.1M
drwxrwxr-x 15 www-data server 4.0K Jun 5 13:29 Sito_SecondDomain
drwxrwxrwx 23 server server 4.0K Jun 7 16:22 Sito_Web_Apache_su_80
drwxrwxr-x 17 www-data server 4.0K Jun 8 09:56 alazanes.tk
Do someone have an idea of what is happening?
Thanks, Francesco