Virtual hosts CNAME redirection problem.

Posted September 8, 2014 5.8k views

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 you will be redirected to

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

A @ |
CNAME * | @

Now lets say user access a, they will always see a page o or http//

Any ideas on how to fix that?

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.

Submit an Answer
1 answer

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:

ServerAlias *