Question

Issue with virtual hosts on centos

I successfully setup virtual hosts on my droplet with CentOS 6.4 x32 I was following this tutorial. https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-centos-6

Everything is good except, some issues.

  1. If I setup virtual hosts, my default landing page is changed and pointing to one of my domain location. I want it to be some specific page or default CentOS setup page. This http://i.imgur.com/NLSJR.png After setting up virtual hosts, my default page is one of my domains page which I do not want.

  2. www.domain.com and domain.com are working fine and pointing to same location/page. But if I type a.domain.com or random.domain.com, it still points to my that location which I do not want. I want it to give error. I assume this random subdomains are pointing to main domain because I added wildcard entry *.domain.com as ServerAlias in httpd.conf. But if I do not add this wildcard then random subdomains points to one of my different domain.

Any ideas on these issues.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You have to set up a default catch-all virtualhost: <br> <br>http://httpd.apache.org/docs/2.0/vhosts/examples.html#default

<VirtualHost *:80> <br> ServerAdmin webmaster@mydomain.com <br> DocumentRoot /home/myuser/mydomain.com/public <br> ServerName www.mydomain.com <br> ServerAlias mydomain.com <br> DirectoryIndex index.html index.php <br> ErrorLog /home/myuser/mydomain.com/log/error.log <br> CustomLog /home/myuser/mydomain.com/log/access.log combined <br></VirtualHost> <br>

I have created 4 virtual hosts right now. And they do have all different DocumentRoot. Here is virtual host entry. <br> <br><VirtualHost *:80> <br> ServerAdmin webmaster@mydomain.com <br> DocumentRoot /home/myuser/mydomain.com/public <br> ServerName www.mydomain.com <br> ServerAlias mydomain.com <br> DirectoryIndex index.html index.php <br> ErrorLog /home/myuser/mydomain.com/log/error.log <br> CustomLog /home/myuser/mydomain.com/log/access.log combined <br></VirtualHost> <br>