我对 nginx 很陌生,只是使用重写规则
我想要我的域名 http://example.com/database/view.php?id=1
显示为 http://example.com/database/id/
GET 参数显示在“id”所在的网址中,这可能吗?
我已经尝试过这个:
rewrite ^/database/$arg_id? /database/view.php?id=[1-9]* last;
和
location @database {
rewrite ^/view/(.*) /view.php?id=$1&$args last;
}
他们失败导致 example.com/database/view/51 为 404
最佳答案
解决它 :)
解决了
rewrite ^/view/(.*)/ /database/view.php?id=$1&$args last;
关于nginx - 如何将GET参数放在nginx重写规则中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28597844/