nginx - 如何将GET参数放在nginx重写规则中?

标签 nginx get rewrite

我对 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/

相关文章:

regex - Haproxy路由和基于URI路径的重写

IIS 重写以删除某些查询字符串参数并重定向到原始请求的主机

ubuntu - 为 Ominbus 安装程序的 GitLab 社区版启用 HTTPS 自签名证书

php - 执行代码以使用 PHP 打开灯

python - 使用gunicorn运行Django : Bad Request (400)

python - 使用 OpenSSL 发送下载页面 - Python

node.js - app.get() 如何处理服务器文件?

internet-explorer - ICE 的 URL 重写问题 - 导致它附加

bash - 如何使用 bash 脚本检查当前的 Web 服务器是 NGINX 还是 Apache?

node.js - 如何在node js中使用express重定向后app.get