Possible Duplicate:
vhost set up help — domain and ip point to the same site

I have recently set up Linux CentOS on a little VPS.

I have bought my own domain and made A records to my VPS like this.

mydomain.com         IP
*.mydomain.com       IP

Everything here works fine.

I've installed Webmin with Apache and everything. Then I've created a Virtual Server in Webmin, to host my website. Also works fine, and I can access it in my browser.

Now I've created a sub-server to host phpmyadmin. I can access this on phpmyadmin.mydomain.com. But also on klweridsncvx.mydomain.com. It catches all subdomains.

It's annoying because I tried to create an Alias to my Google Apps account. mail.mydomain.com should point to ghs.google.com, but it also goes to phpmyadmin.mydomain.com.

Any suggestions how I can get rid of this catchall subdomain?

  • Show us your apache configuration.
    – jippie
    Commented Aug 8, 2012 at 19:30
  • My Apache conf has been created by Webmin, so i guess theres also some unnecessary stuff in there, but i have pasted my 2 Virtual Hosts here, and replaced my real IP and Domain name. Theres my main domain, and the subdomain phpmyadmin. link I think the problem is that the phpmyadmin Virtual Host, is the first on the list, and therefore the default website to show whn i try to access other subdomains which it dont recognize.
    – user21783
    Commented Aug 9, 2012 at 7:12
  • Why close my topic? The duplicate does not cover the same issue as mine, and there is no sulution in the duplicate either..
    – user21783
    Commented Aug 9, 2012 at 14:40
  • @John Conde, of course this is not a duplicate, please re-read the question!
    – jachguate
    Commented Aug 9, 2012 at 18:57
  • 1
    I already know how to create my Virtual Hosts and to make them point to different directories. My problem is that all subdomains points to the default directory, when i just want them to return 404.. Not the same question imo
    – user21783
    Commented Aug 10, 2012 at 8:04

1 Answer 1


Depending in the software you (or your service provider) use in the DNS server, this solution may not work, so test it before accepting.

The usual behavior of the DNS is to try to find a exact match before using any wilcard. This is defined in the section 3.1 of RFC-4592: The Role of Wildcards in the Domain Name System

So, if you make a entry like this in your DNS table, it may work:

mydomain.com.         A IP
mail.mydomain.com.    CNAME ghs.google.com
*.mydomain.com.       A IP

Not current syntax, take is at an example

It may work properly.


Not the answer you're looking for? Browse other questions tagged or ask your own question.