www.site.com and site.com pointing to different folder

January 15, 2015 1.3k views

So i created virtual host on my droplet and connect it with a domain. Also i add CNAME record (www @). But problem is that site.com point to correct folder on server var/www/sitename/public_html, and www.site.com pointing to var/www/html why?

3 Answers

You need to configure your virtualhost to listen on www.site.com as well as site.com.

Under the ServerName site.com line, add the following:

ServerAlias www.site.com

If you already have a ServerAlias directive, simply append www.site.com to the line with a space between each alias:

ServerAlias site2.com ... www.site.com

Then restart Apache:

sudo service apache2 restart
  • That's how i configured it but i had a tipfeler in site.com.conf. Anyway thanks :D

Have another answer? Share your knowledge.