2

I've a webapp running on context "/" and I want now to internationalize it using a subfolder technique.

I want the same site previously hosted under

http://www.mysite.com/

now to serve different languages content under the urls

http://www.mysite.com/en/<br>
http://www.mysite.com/fr/<br>
http://www.mysite.com/de/<br>

I'm thinking in adding an Apache Proxy in front of Tomcat to leave my webapp untouched.

Let's say the app is already supporting i18n based on a cookie present in the request that identifies the language.

With Apache Proxy and Rewrite rule I could strip out the language from the request and add this cookie with the extracted language.

I need then Apache to convert the redirects coming from Tomcat by adding the specific language (passProxyReverse ?)

I need also that the HTML produced by my app is somehow parsed so that links that look like http://www.mysite.com/folder/contact.html are modified into http://www.mysite.com/de/folder/contact.html (mod_proxy_html ?)

I thought about other solutions like deploying the same webapp under different contexts and share sessions through memcache.. or to manage this language subfolder separation directly with some Filter in the webapp and some custom JSTL etc.

All solutions seems a bit too complex.

What I'm trying to achieve is to have a subfolder technique for SEO reasons and to make my webapp not too much aware of this.

I don't understand if I'm complicating it too much..
Are there better/simplier ways to achieve what I need?

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
spike07
  • 809
  • 2
  • 12
  • 21
  • Just rewrite the urls, so the lang part is removed, and then put it in a GET variable. The only thing you would need to change to the webapp code is that it should extract the language from the get-variable instead of from the cookie. Unless the webapp is extracting info from the request_uri, there is no need for proxy. – Gerben Mar 08 '13 at 18:53
  • 1
    thanks. but the webapp still produce html containing absolute urls without the language. The redirects triggered by the webapp controllers also don't take into account the language that was removed by the rewrite – spike07 Mar 08 '13 at 20:09
  • You could create a PHP script in the root that does the 'proxying', and have it replace the url with the new correct ones. PHP would offer more options than using mod_proxy, which can't alter the html anyways. Could be rather strait forward. Parse lang from url. Alter $_COOKIE variable to include the language. Extract the part of the url after the language. Load this file path. Replace all urls to include the language in front. – Gerben Mar 08 '13 at 21:14

0 Answers0