开发者

Prevent hotlinking but allow specified images?

I'm preventing hotlinking with this in htaccess:

RewriteCond %{HTTP_REFERER} !^$
Rewri开发者_如何学GoteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]

However, I'd like to allow certain specified images to be hotlink-able, how do I do this? I can't find anything about it online.

Thanks, Colin


RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteCond %{REQUEST_URI}  !^images/allow-hotlink/.+\.(gif|jpe?g|png)$
RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]


you can add another rewrite condition like so:

RewriteCond %{REQUEST_URI}  !^whitelisted-directory/.*

but its more efficient and easier just to add one write rule that does nothing above and declare it at last like so:

RewriteRule ^(whitlistet-directory1|whitelisted-directory2) - [L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜