Saturday, 14 September 2013

redirect root url according to locale in Zend

redirect root url according to locale in Zend

Working in ZF: Is it possible to change the base or root url on the
www.example.com to www.example.com/$language/home, thus depending on the
(browser) locale of the users browser?
Example; If a guest manually types www.example.com I would like to change
the url automatically to a url with locale: www.example.com/en/home for
guests in en_GB region or www.example.fr/home for guests in fr_FR region.
From the root-url I have all the menu-urls and content locale aware.
Clicking a link to a menu item in the url the lang is automatically added
after the root. The content on the root url is locale aware too using
translate, so english for en_GB en french for fr_FR, etc.
Still missing though I would like to have the root url change to locale
aware right from the start of the visit to the application if only the
root is entered.
I guess something like root :to => redirect("/prepayments") in Rails 3
from what I understand from this Q&A on this forum
I have tried and implemented controller action helpers, redirects, etc.
etc. for as far as I could find on this forum, but they all don't offer
the solution.
A redirect in htaccess is not possible I think since I first need to get
the locale from the browser. Since I don't know this the redirect is
dynamic and I cannot set a redirect in htaccess.
I woud appreciate any suggestions?

No comments:

Post a Comment