.htaccess - redirect requests from a certain IP on

2019-02-20 05:43发布

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 do I achieve this using .htaccess?

1条回答
三岁会撩人
2楼-- · 2019-02-20 06:13

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.

查看更多
登录 后发表回答