linux主机.htaccess文件如何设置图片防盗链

分享到: 更多
By admin, 2009年09月22日

包括godaddy在内的linux主机如何设置防盗链呢, 编辑并上传htaccess文件即可.

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^$ [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} !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]

RewriteRule .(jpg|gif|psd|zip|rar) http://cmszs.com/404.gif [R,NC,L]
</IfModule>

上面几行是允许访问的网站,其中包括搜索引擎和你自己的其他网址,如果想增加的话,再新建几行代码就行了.
最后一行是防盗链的文件类型.用 | 分开.

注意防盗链的404.gif不要开启防盗链!
将以上代码
复制上面的代码到记事本
将RewriteRule .(jpg)中的(jpg)增加你所需要防盗的文件扩展名,如(gif|jpg|rar)用|间隔
然后保存,保存时保存类型选所有文件,编码选ANSI,名称填.htaccess

用上传工具上传到你的主机空间根目录,或是你想要设置防盗链的目录,上传模式一定要是二进制上传,国外主机一般一个小时生效

相关日志

.htaccess 永久重定向
.htaccess用法注意事项小结
Discuz论坛伪静态.htaccess怎么写

随机文章

网页收藏到百度代码,收藏到QQ代码
WordPress错误Fatal error: Maximum execution time of 30 seconds exceeded in
google maps 卫星地图地理坐标源码下载
godaddy主机如何更换操作系统
Godaddy+Windows主机Can not write to cache files, please check directory ./forumdata/
could not load the assembly 'app_web_' Make sure that it is compiled before accessing the page
Discuz7.2风格模板精仿discuz6经典蓝色
discuz 与phpwind 论坛比较分析[转]
免费logo在线制作,免费banner制作,免费图标制作的方法
二级域名转二级目录代码

Comments are closed