Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is not really a programming question, it's more about settings that I can alter visually.

I have bought a domain and am wondering how I can get it work in such a way that everything before the except for things I've already set (like are being forwarded to (or *

so stuff like this:


Goes to the appropriate URL, but:


Are aliases for

The options for adding a rule inside the DNS configuration are:

  • A
  • AAAA
  • MX
  • TXT
  • SRV

Or perhaps it's better to do this with .htaccess? and if so, how should i configure it?

share|improve this question

migrated from Aug 27 '10 at 13:00

This question came from our site for professional and enthusiast programmers.

This is probably better asked at, but do you have access to the zone file? Wild card DNS is easy to set up if you can edit the zone file directly. – bogeymin Aug 27 '10 at 12:49
I've only got access to a control panel with visual tweaking of the DNS and the top-level .htaccess – xaddict Aug 27 '10 at 12:50
I think the dupe question has a clearer answer:…. Perhaps the two questions could be merged? They are, after all, exactly the same question, word for word. – TRiG Aug 29 '11 at 13:36
up vote 4 down vote accepted

You need both:

In DNS zone setup an entry (the last, the best)

*  IN  A   999.999.999.999 # correct this csi-like ip

The last dot in domain is very important.

That will match to your IP. you can place other entries for other subdomains / ip's before.

And in apache / other web server you mus setup a vhost or something to handle all the requests an set ServerAlias / ServerName to

ServerAlias *

Again place this Vhost the lasts, defining any existing vhosts in before the default one.

Apache loads config files using an ascii ordered scheme so put this in a 099_default file and prepend other by 050_

In your case, the DNS should let you to use a * in zone definition and I think you can archieve the apache part using mod_rewrite, if it is enabled. I think that There are some ways of simulate virtual hosting usin rewrites with the SERVER_NAME variable as a condition. Check I haven't tried it.

share|improve this answer

You do this in DNS. If you have a sane (bind-like) dns server you want to add something like this to the configuration for your zone:  A
*       CNAME

It creates an alias for the wildcard and points it to the address of the server.You can also do it directly:

*       A

But for management reasons the first solution is typically better. Once this is done you create a catch-all vhost that mirrors your host.

share|improve this answer

Use a star:


share|improve this answer

It's named jocker. In your DNS configuration put all the names you want and then add the line


All the unknown names will be CNAMED to

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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