Nginx重写的URL无法重定向

时间:2016-12-09 06:39:44

标签: nginx url-rewriting

我一直在尝试重定向该类型的特定网址 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;

我在某处做错了吗?

1 个答案:

答案 0 :(得分: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