Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a website www.example.com pointing to x.x.x.1 and a system with multiples minisites all having subdomains.examples.com 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 www.example.com 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 language.example.com 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 example.com

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

2 Answers 2

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 www.example.com/language/ instead?

Then within your re-write rules you can have (for example) en.example.com redirecting to www.example.com/en/, 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 :
http://mysql-bind.sourceforge.net/

share|improve this answer

Your Answer

 
discard

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.