nginx用wordpress重写链接

我已经断开了我的WP博客上的链接,这是在这条路线上

www.site.com/wp-content/plugins/download-monitor/download.php?id=1 

但是,当我想重新定向到完全新的网站,我的重写规则不起作用。 我用这个

  rewrite ^(/wp-content/plugins/download-monitor/download.php?id=1)(.*)$ http://link.com/my.pdf$2 permanent; 

从你的评论你已经尝试:

 location = /wp-content/plugins/download-monitor/download.php?id=1 { return 301 link.com/my.pdf; } 

这将不起作用,因为location规则无法testingURL的查询string组件。

if块可以用于简单的testing,比如testing$arg_id的值,该值设置为查询string中的id参数的值。 例如:

 location = /wp-content/plugins/download-monitor/download.php { if ($arg_id = 1) { return 301 link.com/my.pdf; } fastcgi_pass ...; ... } 

请注意,上面的location块将处理任何URL指定相同的download.php脚本(即与值不是1值)。 fastcgi指令从您的location ~ \.php$ block中复制 ,以便通常使用非1id值执行download.php脚本。

看到这和这更多。