2016-12-09 177 views
0

我一直在努力的類型的特定URL重定向 https://subdomain.example.com/story_meta_info.php?id=9483https://subdomain.example.com/dash/#/story/9483Nginx的重寫URL未能重定向

我已經使用這個重寫規則嘗試,但它一直在結尾處添加?id=9483

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

我做錯了什麼地方?

回答

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

+0

使用這個我重定向到'的https:// subdomain.example.com/dash /#/ story /' –

+0

這是正在運行的'rewrite ^/story_meta_info \ .php。* https:// $ host/dash /#/ story/$ arg_id?重定向;'。 –

+0

你能否將arg_title更改爲arg_id,然後我可以接受此答案 –