Apache proxypass and multilingual domains

205 views Asked by At

I have a website on domain.com which has multilingual content in URLs e.g.:

  • domain.com/en for english
  • domain.com/de for german
  • domain.com/it for italian

etc. These are not really directories - these are just rewrites that rewrite to /index.php?lang=... So domain.com/lang/one/two/three is rewritten to /index.php?lang=$1&path=$2

It also has domain.com/assets directory that holds all the common files (css, images etc.)

Now I want to change that every language has its own domain which I think could be managed by using mod_proxy, mod_proxy_http and mod_proxy_html in Apache. What I want to achieve is that if user visits:

  • www.domain.com he gets content from domain.com/en
  • www.domain.de he gets content from domain.com/de
  • www.domain.it he gets content from domain.com/it

And if he visits /assets directory from any domain (.com, .de, .it) he would get content from domain.com/assets. Also if user visits URL e.g. www.domain.de/something he should receive content from www.domain.com/de/something

And the other thing are URLs which would have to be rewritten before output so for instance user that browses domain.de would never go to domain.com at all...

Is this possible? Otherwise we would have to reprogram whole CMS to work with different domain for every language...

1

There are 1 answers

1
covener On

It's possible. Just handle them in a single virtualhost and use RewriteCond to examine %{HTTP_HOST} and do the same rewrites you're already doing today. You can capture the country code and backreference it with %1.