将Apache RewiteRule转换为Nginx

时间:2010-12-03 07:20:53

标签: apache mod-rewrite nginx

我刚安装nginx并运行以便在我的网站上提供静态内容。 它工作得很好但是关于图像(ofcourse)停止工作的apache重写规则。

并且我不知道如何转换和在whcih文件中放置。

这就是我在apache上使用的内容:

RewriteCond %{HTTP_REFERER} !^http://(www\.)?imgzzz.com/.*$ [NC]
RewriteRule i/image_(\d+)\.(jpg|jpeg|gif) pic/$1 [L]

其目的是将直接访问的图像重定向到图像页面。

提前致谢:) 欢呼声

1 个答案:

答案 0 :(得分:1)

我自己在做一些研究时得到了答案。把它留在这里以防其他人需要它

location /i/image_ {

location ~ ^/i/image_(?<IMAGE>\d+)\.(jpg|jpeg|gif)$ {
valid_referers imgzzz.com www.imgzzz.com;

if ($invalid_referer) {
rewrite ^ /pic/$IMAGE;
}
}
}