Linux VPS和空间.htaccess文件防盗链写法
代码如下:
<IfModule mod_rewrite.c>
RewriteEngine onRewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !www.deepvps.com [NC]
RewriteCond %{HTTP_REFERER} !bbs.deepvps.com [NC]
RewriteCond %{HTTP_REFERER} !blog.deepvps.com [NC]
RewriteCond %{HTTP_REFERER} !deepvps.com [NC]
RewriteCond %{HTTP_REFERER} !www.zhuaxia.com [NC]
RewriteCond %{HTTP_REFERER} !www.google.com [NC]
RewriteCond %{HTTP_REFERER} !google.com [NC]
RewriteCond %{HTTP_REFERER} !www.google.cn [NC]
RewriteCond %{HTTP_REFERER} !google.cn [NC]
RewriteCond %{HTTP_REFERER} !www.baidu.com [NC]
RewriteCond %{HTTP_REFERER} !www.baidu.cn [NC]
RewriteCond %{HTTP_REFERER} !baidu.com [NC]
RewriteCond %{HTTP_REFERER} !baidu.cn [NC]
RewriteCond %{HTTP_REFERER} !bloglines.com [NC]
RewriteCond %{HTTP_REFERER} !www.ask.com [NC]
RewriteCond %{HTTP_REFERER} !www.163.com [NC]
RewriteCond %{HTTP_REFERER} !www.yahoo.com [NC]
RewriteCond %{HTTP_REFERER} !www.sogou.com [NC]
RewriteCond %{HTTP_REFERER} !www.soso.com [NC]
RewriteCond %{HTTP_REFERER} !www.sina.com.cn [NC]
RewriteCond %{HTTP_REFERER} !www.msn.com [NC]
RewriteCond %{HTTP_REFERER} !www.feedsky.com [NC]
RewriteCond %{HTTP_REFERER} !www.feedburner.com [NC]RewriteRule .(jpg|gif|psd|zip|rar|mp3|txt|png|wma|wmv) http://deepvps.com/404.gif [R,NC,L]
</IfModule>
将deepvps.com改为你的地址!注意防盗链的404.gif不要开启防盗链!
将以上代码,复制上面的代码到记事本
将RewriteRule .(jpg)中的(jpg)增加你所需要防盗的文件扩展名,如(gif|jpg|rar)用|间隔
将 http://deepvps.com/404.gif 改为你想转到的图片网址
然后保存,保存时保存类型选所有文件,编码选ANSI,名称填.htaccess
用上传工具上传到你的主机空间根目录,或是你想要设置防盗链的目录,上传模式一定要是二进制上传,国外主机一般一个小时生效,等等吧!
[复制本文链接发送给您的好友]
沙发为空,还不快抢?[点此发言]