WordPress Download Monitor插件的Nginx重定向规则
Kaijia维护的IMUNC.com需要处理大量文件下载事务,于是启用了WordPress Download Monitor插件。由于Download Monitor默认的下载链接比较长,因此在Download Monitor Configuration中的Custom Download URL中将格式设置成了:
1 |
http://imunc.com/download/文件的ID |
昨天因为访问速度原因将Web服务器从Apache换为Nginx后,发现Download Monitor的Rewrite规则无效了,于是Google找到一个thehook.eu提供的解决方案。
假定设定的自定义URL是“download”,需要编辑Nginx的配置文件,在属于WordPress的Server段底部加入:
1 2 3 4 |
# Download Monitor Rewrite Rule location /download/ { rewrite ^/download/(.*)$ /wp-content/plugins/download-monitor/download.php?id=$1 last; } |
注意替换“download”为你的自定义URL,保存后在终端中运行:
1 |
sudo service nginx restart |
完成后Download Monitor的Nginx重定向规则就会生效了。
更新:新版本的Download Monitor已经不再需要自行设置Nginx规则。
评论