Linux VPS和空间.htaccess文件防盗链写法
- 2024-08-27 05:07:39
- 来源:网络
- 在手机上看
扫一扫立即进入手机端
代码如下:
RewriteEngine on
RewriteCond %{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) https://img.tynpfw.cn/images/20221208/lqipxzpm1na [R,NC,L]
将deepvps.com改为你的地址!注意防盗链的404.gif不要开启防盗链!
将以上代码,复制上面的代码到记事本
将RewriteRule .(jpg)中的(jpg)增加你所需要防盗的文件扩展名,如(gif|jpg|rar)用|间隔
将 https://img.tynpfw.cn/images/20221208/lqipxzpm1na 改为你想转到的图片网址
然后保存,保存时保存类型选所有文件,编码选ANSI,名称填.htaccess
用上传工具上传到你的主机空间根目录,或是你想要设置防盗链的目录,上传模式一定要是二进制上传,国外主机一般一个小时生效,等等吧!