2

I am having an issue with my virtual host setup for days. My server is a vserver with debain linux and I am trying to add two new domains which will be redirected to their own subfolders.

Domain1.com --> /var/www/domain1

Domain2.com --> /var/www/domain2

The setup is working fine, but the domains are not redirecting to the subfolders but the server root directory. So if I open "domain1.com" I get redirected to "domain1.com/mail" which is the roundcube installation.

Here is how I did the setup:

/etc/apache2/sites-available/domain1

<VirtualHost domain1.com> ServerAdmin webmaster@localhost ServerAlias domain1.com *.domain1.com DocumentRoot /var/www/domain1 </VirtualHost> 

/etc/hosts

127.0.0.1 localhost.localdomain localhost domain1.com www.domain1.com 

I just don't get it why it's not redirected to the subfolder... Can someone please tell me what I am doing wrong?

2
  • It's working as designed...DocumentRoot tells Apache what to serve. If you want it to go to another folder, use a redirect. Commented Dec 23, 2013 at 20:08
  • Well yeah the DocumentRoot is the subfolder /domain1 and the index.html which is inside should be displayed if the domain get's called. But if you open the domain you will be redirected to the server's root directory... How would a redirect look like? Commented Dec 23, 2013 at 20:11

1 Answer 1

1

I suspect its because you dont have ServerName directives in your virtualhost stanzas. The domain1.com in <VirtualHost domain1.com> simply tells apache to listen on the address that domain1.com resolves to.

Example VirtualHost Stanza

<VirtualHost domain1.com> ServerName domain1.com ServerAdmin webmaster@localhost ServerAlias domain1.com *.domain1.com DocumentRoot /var/www/domain1 </VirtualHost> 
2
  • thanks for your answer, sadly this doesn't change anything :( Commented Dec 24, 2013 at 11:12
  • Then I suspect you have a stanza somewhere else in your configuration that conflicts with your domain1 and domain2 stanzas. You could perform something like: grep -R VirtualHost /etc/apache2/* to find other virtualhost stanzas in your configuration. If they are not needed, remove them Commented Dec 24, 2013 at 11:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.