Domain Not pointing to the Directory defined in v irtualhost

August 18, 2014 2.9k views

Ubuntu 14 , LAMP
Even after defining the vitualhost in apche2/sites-available/mydomain.com.conf
the domain is still pointing to the var/www/html (which is the default root of server)

The actual directiry defined for mydomain was var/www/mydomain.com/public_html/
but i'm not sure why its not obeying the rule :-(
I have setup two more domains, and they worked smoothly.

1 comment
  • I fixed it by disabling deafult .cnf file. Yes that catch all suggestion is the bonus ;-)

    Thanks U Guys

3 Answers

Could you post your Apache configuration to a pastebin? Without more information, it's hard to know what's going on here.

A few quick troubleshooting points... Did you enable the site configuration?

sudo a2ensite mydomain.com.conf

And make sure to restart Apache after any configuration changes:

sudo service apache2 restart

I got 500 response from www.ardortech.com and [ARDOR TECH VENTURES will be back soon in a new AVATAR!!] from ardortech.com same as http://ip

Did you use the same ServerName in other site configs or 000-default.conf?
Listing /etc/apache2/sites-enabled to is there any other enabled sites.

  • 1) yes, i do have couple of other subdomains and main domains enabled,
    the servername and alias in each sub.domain.com.conf and domain.com.conf are
    sub.domain.com and www.sub.domain.com respectively. and they are working smooth.

    2) in 000-default.conf only doc root is defined , no servernname

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    3) The scenario is, the domain in conflict , is also a servername used while creating the droplet, and if i do type in browser www.mydomain.com it resolves to correct directory, but typing just http://mydomain.com points to the var/www/html which is the root directory for ip address and server ofcourse, but not the desired one.

    Thanks for the responses, waiting for resolution :-)

I would suggest you to disable the 000-deafult.conf
If you want to keep it as a catch all virtualhost for ip / not configured domain which point to the same ip.
Just rename it to like ZZZ-CATCH-ALL.conf and add [serverName default] & [serverAlias *].
The name doesn't matter as long as it is the last in alphabetical order.
000-default.conf may work but making it the last may be better.

Have another answer? Share your knowledge.