开发者

Converting Apache RewiteRule to Nginx's

开发者 https://www.devze.com 2023-01-28 12:01 出处:网络
i just installed开发者_StackOverflow社区 nginx up and running for serving static content on my site.

i just installed开发者_StackOverflow社区 nginx up and running for serving static content on my site. it works great but the apache rewrite rule about images (ofcourse) stoped working.

and i don't have an idea how to convert and in whcih file to put .

This is what i was using on apache :

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

Its purpose is to redirect directly accessed images to the image page instead.

Thanks in advance :) cheers


k i found the answer myself on doing some research. leaving it here in case anyone else needs it

location /i/image_ {

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

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

精彩评论

暂无评论...
验证码 换一张
取 消