Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎样才能为我网站的每个页面重写这个东西?
http://example.org/page.php?locale=en
至
http://example.org/en/page.php
我的部分配置:
if ($host !~* ^www\.){ rewrite ^(.*)$ https://www.example.org$1; } rewrite ^/([0-9a-zA-Z--]+)$ /$1.php last;
谢谢。
尝试在位置块中添加它
rewrite ^/([^/])(/.*) $2?locale=$1&$query_string last;
如果您只有某些语言环境,那么出错的空间就会更小,您可以用类似的东西替换正则表达式,例如
rewrite ^/([en|fr|de])(/.*) $2?locale=$1&query_string last;
就像是:
Rewrite ^/page.php?id=(.*)$ /$1/page.php;
这对你有用吗?