基于ip管理zend中的多语言站点

I have a site which I made multilingual. It is based on user ip. For example if user is in china then site will open in Chinese language. There is no change in url.

Now I want that if user open the site from china then url become ch.example.com, How can I do it ? I am using zend framework. I have to do it so Google can crawl Chinese version on website.

I can do it by making a sub-folder like example.com/ch but I don't want to manage site in different folder .

What can be the best way to do it.

Thanks

So assuming that you are mapping all of the different language subdomains to the same server, and you are using Apache, you can do the following:

  1. Create an Apache virtual host for each language subdomain. Each of these virtual hosts should point to your same Zend Framework application document root.

  2. For each of these virtual hosts, you can create an APPLICATION_LANGUAGE environment variable that sets the relevant language value.

  3. You can then check against this environment variable in your Zend application to toggle your language toggling business logic.