若森志

02 Mar, 2008

.htaccess防盗链

Posted by: admin In: 我就不分类

由于盗链严重,上月流量超了限额,不过空间商还算人性化,我没有像chada一样被关。

吃一堑,长一智。在网上找到了一个方法,感谢zhang的方法!

前提Apache中的mod_rewrite模块为激活状态,

编辑网站根目录的.htaccess文件,没有的话就新建一个,并复制以下内容保存。

  1. <ifmodule mod_rewrite.c>  
  2. #开启mod_rewrite引擎   
  3. RewriteEngine On  
  4. #设置合法请求源   
  5. RewriteCond %{HTTP_REFERER} !^$ [NC]   
  6. RewriteCond %{HTTP_REFERER} !ruosen.com[NC]   
  7. RewriteCond %{HTTP_REFERER} !google.com [NC]   
  8. RewriteCond %{HTTP_REFERER} !baidu.com [NC]   
  9. RewriteCond %{HTTP_REFERER} !yahoo.com [NC]   
  10. RewriteCond %{HTTP_REFERER} !msn.com [NC]   
  11. RewriteCond %{HTTP_REFERER} !bloglines.com [NC]   
  12. RewriteCond %{HTTP_REFERER} !feedburner.com [NC]   
  13. RewriteCond %{HTTP_REFERER} !feedsky.com [NC]  
  14. #指向警告页面   
  15. RewriteRule .*\.(gif|jpg|png|mp3)$ outlink.gif [L,NC]   
  16. </ifmodule> 

如果已经有wordpress自动创建的内容了,就只在RewriteEngine On  后面,</ifmodule> 前面加上

  1. RewriteCond %{HTTP_REFERER} !^$ [NC]   
  2. RewriteCond %{HTTP_REFERER} !ruosen.com[NC]   
  3. RewriteCond %{HTTP_REFERER} !google.com [NC]   
  4. RewriteCond %{HTTP_REFERER} !baidu.com [NC]   
  5. RewriteCond %{HTTP_REFERER} !yahoo.com [NC]   
  6. RewriteCond %{HTTP_REFERER} !msn.com [NC]   
  7. RewriteCond %{HTTP_REFERER} !bloglines.com [NC]   
  8. RewriteCond %{HTTP_REFERER} !feedburner.com [NC]   
  9. RewriteCond %{HTTP_REFERER} !feedsky.com [NC]  
  10. #指向警告页面   
  11. RewriteRule .*\.(gif|jpg|png|mp3)$ outlink.gif [L,NC]

其中ruosen.com改为你自己的地址

Tags:

12 Responses to ".htaccess防盗链"

1 | My-Hou不務正業

03月 2nd, 2008 at 9:22 pm

Avatar

最怕图片给盗了~~~不单流量,而且速度都受影响

2 | ruosen

03月 3rd, 2008 at 12:08 am

Avatar

是啊。。。

3 | George

03月 3rd, 2008 at 6:23 pm

Avatar

大涨见识

4 | Francis

03月 3rd, 2008 at 6:47 pm

Avatar

没这功能……

5 | SunQ

03月 3rd, 2008 at 8:55 pm

Avatar

幸好我的流量不大,还不会有盗链的情况出现,呵呵

6 | ruosen

03月 3rd, 2008 at 8:57 pm

Avatar

我晕啊,又是乱码。。。

8 | 111

03月 3rd, 2008 at 9:05 pm

Avatar

继续测试

9 | chada

03月 3rd, 2008 at 9:43 pm

Avatar

上次看你的一篇日志也是出现乱码,怎么会这样呢?

10 | ruosen

03月 3rd, 2008 at 11:09 pm

Avatar

总是在高峰时段乱。。。

11 | eDWARD

03月 6th, 2008 at 11:51 am

Avatar

赫赫,发现了反向链接找过来的:) 可以考虑建立个链接:)

12 | ruosen

03月 6th, 2008 at 5:51 pm

Avatar

很高兴能链接你,我已加

Comment Form

Categories

Feed

What I'm Doing...

Posting tweet...

想要友情链接的要先做好本站链接
友链要求:PR大于等于3,顶级域名的博客

Flickr PhotoStream

  • bbb
  • ccc
  • ddd
  • 20080616_6a79669c7648a2389e98GtHVM5ltIv2P

About

既然你诚心诚意地问了,我们就大慈大悲地告诉你,为了防止世界被破坏,为了维护世界的和平,贯彻爱与真实的罪恶,可爱而又迷人的个人博客。就是!若森志!我们是穿梭于墙内外的敢死队,互联网的明天等着我们,就是这样,喵!

关闭
E-mail It