mod_rewrite 防盗链 Apache中利用mod_rewrite实现防盗链

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

mod_rewrite 防盗链 Apache中利用mod_rewrite实现防盗链

  2021-03-17 我要评论
想了解Apache中利用mod_rewrite实现防盗链的相关内容吗,在本文为您仔细讲解mod_rewrite 防盗链的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:mod_rewrite,防盗链,下面大家一起来学习吧。
 前提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> 

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们