【发布时间】:2012-06-05 14:49:41
【问题描述】:
我将 Joomla 与 Nginx 结合使用,我目前正在尝试为支持多种语言(意大利语、法语、中文和德语)的网站实现一些 URL 重写
网址后面有国家代码,像这样:http://www.example.com/fr/test/test.html
或http://www.example.com/de/test/test.html
我正在寻找重写网址,以便国家代码成为子域的一部分:
所以http://www.example.com/fr/test/test.html
变成http://fr.example.com/test/test.html
有没有办法通过 Nginx 实现这一点,或者我应该研究 Joomla 的第三方扩展(不是我最喜欢的选择)。
谢谢!!
更新:
我不够清楚:我希望来自重写 URL 的重定向是透明的。这是我想出的,感谢 VBart 的帮助:
server {
server_name ~^(?<lang>.+)\.example\.com$;
location / {
rewrite /(.*)$ /$lang/$1 break;
proxy_pass http://www.example.com;
proxy_redirect http://www.example.com http://$lang.example.com/$request_uri;
}
}
现在,Nginx 有没有办法在提供的内容中动态修改链接?即:我希望生成页面中的所有链接看起来像http://fr... 而不是http://.../fr/...?
【问题讨论】:
标签: joomla url-rewriting nginx multilingual