Nginx将带有参数的PHP请求redirect到其他页面

我也许有一个简单的问题。 我想redirect这个myBB的页面:

/misc.php?action=help&hid=10 

对于这个:

 /document.html 

我在nginx的vhostconfiguration中试过这个:

 location /misc.php?action=help&hid=10 { return 301 /document.html; } 

但它没有工作…

欢迎来到serverfault.com

 location /misc.php { if ($args = "action=help&hid=10") { return 301 /document.html; } } 

nginx location指令与查询参数不匹配。 因此,您需要使用上面的Federico描述的if方法。

但是,如果您希望由PHP处理/misc.php其他请求,则需要在location块中进行额外的configuration。 例如,您需要包含与您的location ~ \.php$ block中相同的FastCGI语句。