【问题标题】:Nginx rewritten URL fails to redirectNginx 重写 URL 重定向失败
【发布时间】:2017-04-24 13:57:41
【问题描述】:

我一直在尝试重定向该类型的特定 URL https://subdomain.example.com/story_meta_info.php?id=9483https://subdomain.example.com/dash/#/story/9483

我曾尝试使用此重写规则,但它一直在末尾添加?id=9483

rewrite ^/story_meta_info\.php.* https://$host/dash/#/story/$arg_title redirect;

我是不是在某处做错了什么?

【问题讨论】:

    标签: nginx url-rewriting


    【解决方案1】:

    如果替换字符串包含新的请求参数,则之前的请求参数会附加在它们之后。如果这是不希望的,在替换字符串的末尾放置一个问号可以避免附加它们,例如:

    rewrite ^/story_meta_info\.php.* https://$host/dash/#/story/$arg_id? redirect;
    

    来源:http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

    【讨论】:

    • 这是有效的rewrite ^/story_meta_info\.php.* https://$host/dash/#/story/$arg_id? redirect;
    • 能否将 arg_title 更改为 arg_id,然后我可以接受这个答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    相关资源
    最近更新 更多