Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Country Specific Request Redirection

 
Pankaj Patel
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all.

I have one site namely x.com which is available in two different language(English, China). Now i want to decide that if request comes from China then i need to redirect user to china.x.com else english.x.com.

For that i have two option.
1) Identify the country based on IP Address. (User Linux Command whois IP_ADDRESS)
2) Use request.getLocale() which will return me the language of browser.


-> As i had checked for www.google.com, it is working on request.getLocale() if my language is other then English. And if English then it redirects to Country Specific.


Which step should i use? if both then in which order. According to the Google it is second and then first.


Can anybody please guide/help me in this context ?



===========================================================
Thanks & Regards,
Pankaj Patel
SCJP 5.0
-----------------------------------------------------------
Enjoy the World of Programming....
===========================================================
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The location where a request originates has only a loose correlation (sometimes none) with the language that the response should be in. The important criterion is the Accept-Language request header; it tells you which language the client prefers.
 
Pankaj Patel
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.


I got your point. I will desing code on ACCEPT_LANGUAGE.



Thanks & Regards,
Pankaj Patel
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!