Question

Virtual hosts CNAME redirection problem.

  • Posted on September 8, 2014
  • decaobrAsked by decaobr

I Currently have a apache server running, with multiple sites in it i followed this tutorial, to setup everything, but i having a problem.

Lets say if you access my ip address like http://0.0.0.0 you will be redirected to example.com.

Now on my DNS settings off all my domains, a have the Following Configurations:

A @ | 0.0.0.0 CNAME * | @

Now lets say user access a anything.AnotherSiteOnSameHost.com, they will always see a page o example.com or http//0.0.0.0

Any ideas on how to fix that?


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.

A wildcard CNAME will direct any subdomain to that IP address. Apache then sends any request that don’t match a specific VirtualHost to the default one.

If you don’t want any random subdomain to lead to your site, then you can just use individual CNAMES for each subdomain instead of a wildcard. If you want unknow subdomains to redirect to the root domain, you can add a wildcard ServerAlias to the VirtualHost like so:

ServerName domain.com
ServerAlias *.domain.com