开发者

.htaccess - redirect requests from a certain IP only

I believe someone is scraping images from my site. So what I want to do is, based on their specific IP address, serve up some kind of holding image instead of the actual image.

How d开发者_如何学编程o I achieve this using .htaccess?


Try this mod_rewrite rule:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} =12.34.56.78
RewriteRule !^images/foobar\.png$ images/foobar.png

This rule will rewrite any request from the IP address 12.34.56.78 that is not /images/foobar.png internally to /images/foobar.png.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜