【问题标题】:How to write a main url rewrite in nginx如何在 nginx 中编写主 url 重写
【发布时间】:2014-05-23 15:59:28
【问题描述】:

我想将网址:www.example.com/index.html?id=roy 更改为: www.example.com/roy

我试过this solution,但它是针对url:www.example.com/users/roy

【问题讨论】:

    标签: nginx url-rewriting rewrite


    【解决方案1】:

    请试一试。这会将/(.+) 重写为/index.html?id=$1

    rewrite ^/(.+)$ /index.html?id=$1 last;
    

    【讨论】:

    • 我得到 500 内部服务器错误,当我输入 www.somedomain.com 时,为什么?
    • 请发布您的配置
    【解决方案2】:

    我解决了这个问题: try_files $uri/ $uri /index.html?$query_string

    【讨论】:

      【解决方案3】:

      试试这个,(使用无限的名字)

      location / {
        rewrite ^ http://www.example.com/users/$arg_id permanent;
      }
      

      【讨论】:

        猜你喜欢
        • 2011-05-18
        • 2019-01-24
        • 1970-01-01
        • 2013-11-08
        • 1970-01-01
        • 2019-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多