-1

So. I have three sites, which are located at the same host:

  • example.com
  • example2.com
  • sub.example.com

Files on servers are located like this:

/var/www/example.com
/var/www/example2.com
/var/www/example.com/sub

I have three vhosts:

  • 000-default.conf

    <VirtualHost *:80>
      ServerName example.com 
      ServerAlias www.example.com   
      ServerAdmin webmaster@localhost   
      DocumentRoot /var/www/example.com 
    </VirtualHost>
    
  • example2.conf

    <VirtualHost *:80>
      ServerName example2.com 
      ServerAlias www.example2.com  
      ServerAdmin webmaster@localhost   
      DocumentRoot /var/www/example2.com    
    </VirtualHost>
    
  • sub.conf

    <VirtualHost *:80>
      ServerName sub.example.com 
      ServerAlias www.sub.example.com   
      ServerAdmin webmaster@localhost   
      DocumentRoot /var/www/example.com/sub 
    </VirtualHost>
    

So, example.com and example2.com work without problem. But sub.example.com redirects all requests to /var/www and shows folders listings. Is there some specific configuration for subdomain vhosts?


Update: I tried one more time to move sub to /var/www and rewrite sub vhost. After restart in some magic way it works. Bu i still can't understand why, Although, problem is solved

  • If there is no specific reason to have sub.example.com docroot under example.com domain, I would move it to completely separate place from example.com. – Tero Kilkanen Jul 8 '15 at 17:55
  • What exactly do you mean by "redirects all requests to". Can you give a more concrete example what this redirect is? – Tero Kilkanen Jul 8 '15 at 17:56
  • @TeroKilkanen - do you mean physical location? I tried to move folder sub to /var/www - but it works in the same way. If i visit sub.example.com, apache redirects me to /var/www folder listing. For example, sub.example.com/index.html gives me 404 (on apache log i have error - /var/www/index.html not found). That is what i mean – core_st Jul 8 '15 at 17:58
  • Configure separate logs for each site (which I find a good ideea to do whenever there are multiple sites on one server). Then see which site is chosen to serve sub.example.com so you know where to start debugging – Dan Jul 8 '15 at 18:09
  • @Dan i have separate logging. When i'm trying to get access to sub.example.com/index.php - error appears in general log (/var/www/index.php not found) and error_sub.log is still empty – core_st Jul 8 '15 at 18:16
0

Update: I tried one more time to move sub to /var/www and rewrite sub vhost. After restart in some magic (with /var/www/sub as RootDirectory) way it works. But i still can't understand why, Although, problem is solved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.