Adding a prefix to every URL in CakePHP

后端 未结 3 590
感情败类
感情败类 2020-12-04 17:15

What\'s the cleanest way to add a prefix to every URL in CakePHP, like a language parameter?

http://example.com/en/controller/action
http://example.com/ru/ad         


        
3条回答
  •  星月不相逢
    2020-12-04 17:31

    An easier way might be to store the chosen language in a cookie and then not have to rewrite all the URLs. You could also potentially detect the user's browser language automatically.

    However, search engines would be unlikely to pickup the various languages and you'd also lose the language if someone tried to share the link.

    But love the full solution you posted, very comprehensive, thanks. :-)

提交回复
热议问题