我想要这个简单的重写规则:
http://example.com/8743b52063cd84097a65d1633f5c74f5?param1=999¶m2=2222
重定向至:
http://example.com/index.php?param1=999¶m2=2222&hash=8743b52063cd84097a65d1633f5c74f5
以下是我的默认位置:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
如何使用 Nginx 重写来实现此目的?
最佳答案
使用 rewrite statement :
rewrite "^/(\w{32})$" /index.php?hash=$1 last;
或者,在location block内:
location ~ "^/(?<hash>\w{32})$" {
rewrite ^ /index.php?hash=$hash last;
}
关于nginx - 如何使用 Nginx 重写将 url 段转换为查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43906896/