开发者

Apache/.htaccess

开发者 https://www.devze.com 2023-02-15 02:13 出处:网络
I\'ve got problem, I want to prevent hotlinking from some subdomain in specified directory. Let\'s say, that we\'ve got images at:

I've got problem, I want to prevent hotlinking from some subdomain in specified directory. Let's say, that we've got images at:

http://s1.domain.com/media/image1.jpg

http://s1.domain.com/media/image2.jpg

As default it is access to these locations, and users can see this photos. I want to prevent from hot linking, but with no error message, but with redirection, so if user put this address into browser (http://s1.domain.com/media/image1.jpg), i want to redirect it do PHP script, as: domain.com/filename/开发者_Go百科image1.jpg. I want to make it with .htaccess. So please, can you give me code to put into this file.

Thanks for responses!


in the httpd.conf try this..

SetEnvIfNoCase Referer "^http://www\.yourdomain\.com/" banimages=1
SetEnvIfNoCase Referer "^http://yourdomain\.com/" banimages=1
SetEnvIfNoCase Referer "^$" banimages=1
<FilesMatch "\.(gif|png|jpe?g)$">
  Order Allow,Deny
  Allow from env=banimages=1
</FilesMatch>

or

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ - [F] 

or some other techniques also available..

0

精彩评论

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

关注公众号