【www.gdgbn.com--apache】

目前有一种产品能比较好地支持iis的urlrewrite,名字叫isapi_rewrite。

对于我的网站,我防盗链的方法是在httpd.ini里面加入如下语句

rewritecond host: (.+)

rewritecond referer: (?!http://1.*).*

rewriterule .*.(?:gif|jpg|png|exe|rar|zip) /block.gif [i,

 

o]


修改安装目录中的httpd.ini文件(如果这个文件为“只读”属性,则去掉“只读”之后再修改)
添加:

rewritecond host: (.+)
rewritecond referer: (?!http://1.*).*
rewritecond referer: (?!http://(.*)(.baidu.com|.google.com|.google.cn|.g.cn|.gougou.com|.soso.com|.sogou.com|.youdao.com|.bing.com|.yahoo.com|.yahoo.cn|.eojoo.com)).*
rewriterule .*.(?:gif|jpg|jpeg|png|bmp) /block.gif [i,o,n]


apache

开启图片防盗链功能需要在htaccess文件中加入以下代码:

  rewriteengine on
  rewritecond %{http_referer} !^$
  rewritecond %{http_referer} !^http://(www.)?allow1.com(/)?.*$ [nc]
  rewritecond %{http_referer} !^http://(www.)?allow2.com(/)?.*$ [nc]
  rewriterule .*.(gif|jpg|jpeg|bmp|png)$ [r,nc,l]

本文来源:http://www.gdgbn.com/jiaocheng/29549/