使用防盗链

发布于 2025-01-07 22:11:18 字数 560 浏览 2 评论 0原文

我想知道如何在以下代码中定位图片:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://dooomain.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://www.dooomain.com/.*$ [NC]
RewriteRule .*.jpg$ -                           [L]

不太确定必须在哪里插入 jpg 文件!它是在网络根文件夹中还是在哪里?

谢谢

更新#1

好吧,也许我找到了一些答案,但不确定,所以如果我错了,请大家纠正我...

这是我应该添加的代码,而不是最后一行我的主要帖子:

RewriteRule \.(gif|jpg)$ https://www.mydooomain.com/pic.gif [R,L]

在这种情况下我需要将图片放在根目录中,对吗???

谢谢

I'm wondering how to target the picture in this following code:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://dooomain.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://www.dooomain.com/.*$ [NC]
RewriteRule .*.jpg$ -                           [L]

not really sure where I have to insert the jpg file!! is it in the web root folder or where?

Thanks

Update #1

ok, maybe I found something to my answer, but not sure so please guys correct me if I'm wrong...

here is the code I should add instead of the last line in my main post:

RewriteRule \.(gif|jpg)$ https://www.mydooomain.com/pic.gif [R,L]

and I need to place the picture in the root in this case, is that right???

Thanks

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

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

发布评论

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

评论(1

羁〃客ぐ 2025-01-14 22:11:18

上面的最后一条规则很好。但是 rewritecond 可以在一行中完成。

RewriteCond %{HTTP_REFERER} !^(?:$|http://domain.com|http://www.domain.com) [NC]
RewriteRule \.(gif|jpg)$ https://www.mydomain.com/pic.gif [R,L]

The last rule above is fine. But rewritecond can be done in a single line.

RewriteCond %{HTTP_REFERER} !^(?:$|http://domain.com|http://www.domain.com) [NC]
RewriteRule \.(gif|jpg)$ https://www.mydomain.com/pic.gif [R,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文