我希望使用mod重写在我们的网站中使用语言切换。而不是显示:
https://www.website.com/rest/of/my-site?lang=it
https://www.website.com/en/rest/of/my-site
问题来了。 我们当前的mod重写配置:
# General rewrites
RewriteRule -p([0-9]+)\.html$ index.php?module=page&id=$1&%{QUERY_STRING} [L]
RewriteRule (news|nieuws)/(.*)\.html$ index.php?module=news&url_raw=$2&%{QUERY_STRING} [L]
RewriteRule (.*)\.html$ index.php?module=page&url_raw=$1&%{QUERY_STRING} [L]
#rewriteRule contact(/|)$ index.php?module=contact&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ index.php?module=page&url_raw=$1&%{QUERY_STRING} [L]
B Mod重写和PHP片段 当mod重写工作时,用户应该能够从
切换而不是
我已经尝试了几个选项(language parameter rewrite with mod_rewrite),但我对它的了解还不够。
答案 0 :(得分:0)
尝试将此添加到规则的顶部:
RewriteCond %{THE_REQUEST} \ /+(.*)\?(.*?)&?lang=([^&\ ]+)([^\ ]*)
RewriteRule ^ /%3/%1?%2%4 [L,R]
RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteRule ^([a-z][a-z])/(.*)$ /$2?lang=$1 [L,QSA]