首页 > 开发 > Apache > 正文

rewrite 技术实现 Apache 防盗链

2020-10-12 18:50:41
字体:
来源:转载
供稿:网友

apache 防盗链的第一种实现方法,可以用 rewrite 实现。首先要确认 apache 的 rewrite module 可用:能够控制 apache httpd.conf 文件的,打开 httpd.conf,确保有这么一行配置: 

  1. loadmodule rewrite_module modules/mod_rewrite.so 

在找到自己网站对应的 配置的地方,加入下列代码: 

  1. servername Cuoxin.com  
  2. # 防盗链配置  
  3. rewriteengine on  
  4. rewritecond %{http_referer} !^http://Cuoxin.com/.*$ [nc]  
  5. rewritecond %{http_referer} !^http://Cuoxin.com$ [nc]  
  6. rewritecond %{http_referer} !^http://www.Cuoxin.com/.*$ [nc]  
  7. rewritecond %{http_referer} !^http://www.Cuoxin.com$ [nc]  
  8. rewriterule .*.(gif|jpg|swf)$ http://www.Cuoxin.com/about/nolink.png [r,nc] 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表