|
本帖最后由 拼命二郎 于 2024-3-23 17:56 编辑
求助各位大佬,网上那种转化工具无效,让chatgpt写也无效,请教各位专业的大佬
国外的cms,它自带多语言系统(访问www.abc.com自动跳转到www.abc.com/fr),但是它是基于apache开发的,所以伪静态规则是.htaccess的(如下),我用的是宝塔+Nginx,想将这个伪静态规则转化为适合nginx的,求各位大佬帮助
- RewriteCond %{ENV:REDIRECT_REWRITTEN} !=1
- RewriteCond %{ENV:REDIRECT_REDIRECT_REWRITTEN} !=1
- RewriteRule ^([a-z]{2})/(.*) /$2 [L,QSA,E=REWRITTEN:1,E=LOCALE:$1]
复制代码
官方人员给的建议是:So you need to either find a way to set this (the rule is setting environmental variables REDIRECT_LOCALE=<language code> that is used later by script to switch to a specific locale), or to switch to using subdomains.
chatgpt写的代码如下,不能用
- location ~ ^/([a-z]{2})/(.*) {
- if ($redirect_rewritten != "1") {
- rewrite ^/([a-z]{2})/(.*) /$2 last;
- set $locale $1;
- }
- }
复制代码 |
|