共计 667 个字符,预计需要花费 2 分钟才能阅读完成。
本帖最后由 拼命二郎 于 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= 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;
}
} 复制代码