网站防盗链的设置方法
apache和iis6实现防盗链规则相同,在isapi筛选器开启自定义url静态化支持(一般的虚拟主机商都会提供),然后进入httpd.conf中,复制以下代码加进去:RewriteEngine on
RewriteCond %{HTTP_REFERER} !baidu.com
RewriteCond %{HTTP_REFERER} !google.com
RewriteCond %{HTTP_REFERER} !xxx.net
RewriteRule .*\.(gif|jpg)$ /band.txt
ips:xxx.net是您自己的域名,band.txt是被盗链后的提示内容文件。iis7实现防盗链则需要修改web.config文件,复制以下代码保存即可:<?xml version="1.0" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Prevent hotlinking">
<match url="^.*\.(rar|zip|jpg|gif)$" ignoreCase="true" />
<conditions>
<add input="{HTTP_REFERER}" pattern="http://www.xxxxxx.com/.*" negate="true" />
<add input="{HTTP_REFERER}" pattern="http://xxxxxx.com/.*" negate="true" />
</conditions>
<action type="Rewrite" url="/404.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
页:
[1]