Linux下规则文件.htaccess(手工创建.htaccess文件到站点根目录) <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_REFERER} !baidu.com [NC] RewriteCond %{HTTP_REFERER} !google.com [NC] RewriteCond %{HTTP_REFERER} !xxx.net [NC] #RewriteCond %{HTTP_REFERER} !^$ [NC] RewriteRule .*\.(gif|jpg|png|css|js)$ /band.txt [NC,L] </IfModule> 注:xxx.net是您自己的域名,band.txt是被盗链后的提示内容文件 Windows2008、2012或更高系统下规则文件web.config (手工创建web.config文件到站点根目录) <?xml version="1.0" ?> <configuration> <system.webServer> <rewrite> <rules> <rule name="rule1" stopProcessing="true"> <match url="^.*\.(css|js|gif|png|jpg|jpeg)$" ignoreCase="true" /> <conditions> <add input="{HTTP_REFERER}" pattern="您的域名.com(不用加www)" negate="true" /> <!--<add input="{HTTP_REFERER}" pattern="^$" negate="true" />--> </conditions> <action type="AbortRequest" /> </rule> </rules> </rewrite> </system.webServer> </configuration> |