.htaccess - 仅重定向来自特定 IP 的请求

发布于 2024-09-28 01:08:33 字数 93 浏览 0 评论 0原文

我相信有人正在从我的网站上抓取图像。所以我想做的是,根据他们的特定 IP 地址,提供某种持有图像而不是实际图像。

如何使用 .htaccess 实现此目的?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷清清 2024-10-05 01:08:33

尝试这个 mod_rewrite 规则:

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

此规则会将来自 IP 地址 12.34.56.78 的任何非 /images/foobar.png 内部请求重写为 /images/foobar.png

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文