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.

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 francesco@firstdomain.com
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 lastdomain.tk

Do someone have an idea of what is happening?

Thanks, Francesco

Update

Even if I use a subdirectory it is 301 redirected, like if I navigate to

lastdomain.tk/install

I'm redirected to

firstdomain.com/install
share|improve this question
    
What content is in the lastdomain.tk directory? –  Shane Madden Jun 9 '12 at 19:31
    
@ShaneMadden at the beginning it was only an index.html with something like "This is a test page". Now it contains Joomla's installation files.. –  Francesco Jun 9 '12 at 23:20
    
Check if it stops redirecting with the Joomla files removed. If you don't have Apache configured to 301 redirect, it's not capable of doing so - so if the config doesn't have the redirect, then the source of it is guaranteed to be the dynamic content. –  Shane Madden Jun 9 '12 at 23:25
    
@ShaneMadden I've tried removing Joomla's files, but the problem remains.. I'm thinking about purging apache's configurations and have it done from scratch... –  Francesco Jun 12 '12 at 11:23

1 Answer 1

Your question seemed to be a bit over the place but I get the general idea of what you are looking for as per your problem. The issue may be due to how you havn't created a folder in /home/server/Condivisione/RAID/ for lastdomain.tk. You can do so by mkdir /home/server/Condivisione/RAID/lastdomain.tk.

When you created the lastdomain.tk config, webmin should have looked like:

Handle connections to address -- Any Address
Add name virtual server address (if needed) -- Checked
Listen on address (if needed) -- Checked
Port -- 80
Document Root -- /home/server/Condivisione/RAID/lastdomain.tk
Allow Access to this directory -- Checked
Server Name -- lastdomain.tk
Add virtual server to file -- New file under virtual servers directory /etc/apache2/sites-available
Copy directives from -- Nowhere

After creating this, make sure you go to Virtual Server (for lastdomain.tk) and click on Networking and Addresses and set:

Alternate virtual server names: www.lastdomain.tk
Server admin email address: your@email.com

Once done with that, head back over to your virtual server and click on Aliases and Redirects and make sure there is nothing set under Permanent URL redirects (Code 301). If there is, remove it.

After all of that; select Apply Changes.

If you still are having issues with this; comment and i'll try to get back to you.

Hope this helps and DFTBA. :)

share|improve this answer
    
about folder missing my mystake, I've forgotten to change ls output to mask (real) lastdomain.tk. Folder is there and permission seems ok. –  Francesco Jun 9 '12 at 15:25
    
about webmin I've tried removing virtual server and recreating with your configurations but the behavior is the same. Double checked that there is no 301 redirect. Only 301 redirect I use is into firstdomain.com's .htaccess to redirect firstdomain.com to www.firstdomain.com. Thank you for your time. –  Francesco Jun 9 '12 at 15:34

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.