【问题标题】:How to put the GET parameter in nginx rewrite rule?如何将 GET 参数放入 nginx 重写规则中?
【发布时间】:2015-02-19 02:45:33
【问题描述】:

我对 nginx 很陌生,只是使用重写规则

我想要我的域名http://example.com/database/view.php?id=1

显示为http://example.com/database/id/

在“id”所在的 url 中显示 GET 参数,这可能吗?

我已经尝试过了:

 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

【问题讨论】:

  • 您的应用程序是否有单一入口点?如果没有 - 你得到 404,因为 Nginx 在给定的路径找不到任何东西。

标签: nginx get rewrite


【解决方案1】:

修复它:)

解决了

rewrite ^/view/(.*)/ /database/view.php?id=$1&$args last;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多