首页 > 开发 > Apache > 正文

Apache中利用mod_rewrite实现防盗链

2020-04-16 19:24:27
字体:
来源:转载
供稿:网友
 前提Apache中的mod_rewrite模块为激活状态,既然要消灭掉mp3文件的盗链就顺便也把图片盗链的设置给做了,下面是我在网站根目录的.htaccess文件中的配置,供同病相怜之人参考:。 
view plaincopy to clipboardprint?<ifmodule mod_rewrite.c>  #开启mod_rewrite引擎   RewriteEngine On  #设置合法请求源   
  1. <ifmodule mod_rewrite.c>  
  2. #开启mod_rewrite引擎   
  3. RewriteEngine On  
  4. #设置合法请求源   
  5. RewriteCond %{HTTP_REFERER} !^$ [NC]   
  6. RewriteCond %{HTTP_REFERER} !zhangzhang.net [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> 

您可能感兴趣的文章:

开启Apache mod_rewrite模块示例代码13个实用的Apache Rewrite重写规则Apache伪静态Rewrite详解如何在Ubuntu下启动Apache的Rewrite功能浅析Apache中RewriteCond规则参数的详细介绍浅谈apache和nginx的rewrite的区别Apache Rewrite实现URL的301跳转和域名跳转apache中通过mod_rewrite实现伪静态页面的方法Linux下Apache安装/增加mod_rewrite模块的方法Apache Rewrite url重定向功能的简单配置让Apache支持Rewrite静态页面重写的方法Linux下Apache安装/增加mod_rewrite模块的方法apache urlrewrite防盗链功能配置学习Apache的mod rewrite、access写法Apache rewrite的重写相关的参数说明Apache rewrite重写规则的常见应用apache rewrite_module模块使用教程apache的rewrite规则使用说明
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表