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

We have a website pointing to x.x.x.1 and a system with multiples minisites all having pointing to x.x.x.2

Basically what we have in place is a wildcard DNS entry who could basically match any possible subdomain, once reaching x.x.x.2, the apache vhost would intercept and basically redirect it to a php script who in turn would know what minisites to serve.

On however, we server contents which are translates in several languages, until few weeks ago you could switch languages by clicking on a flag and you'd be served with the translated content. The only problem is that the URL wouldn't change and SEO wise this isn't the best solution.

Now I cannot change the way subdomain are handled (being redirected to x.x.x.2) since we have hundreds, if not thousands of minisites live.

I have to come up with a solution to have redirecting to x.x.x.1 and then a rewrite rule who would basically rewrite the fake subdomain into a URL in order to pass the parameter of the language to

On solution is to list all possible language as DNS entries right before the wildcard DNS entry. The other solution which I am almost sure is not feasible is to have some kind of regex in a DNS entry matching all subdomain with 2 letters ( en|es|fr|cn|cl etc... )

Any ideas?

share|improve this question
up vote 1 down vote accepted

You can't do the two letter match in DNS, a wildcard specifically matches one or more labels, and that's the full extent of pattern matching in DNS.

Have you considered using instead?

Then within your re-write rules you can have (for example) redirecting to, and that can be done based on conditional tests that check whether that particular language's subdirectory exists.

If there's no match for that subdirectory when it would represent one of your mini-sites instead.

share|improve this answer

Have you considered :

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.