apche+php网站防盗链

samool 发布暂无评论9249 阅读

AI摘要

本文介绍了如何通过修改.htaccess文件来防止APACHE+PHP网站被非法链接。具体方法是启用RewriteEngine,设置四个RewriteCond条件来排除合法的HTTP_REFERER,然后使用RewriteRule将非法链接重定向到错误页面。需要将示例中的网址替换为实际网址,并将错误页面设置为绿色。

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.samool.com/.*$ [NC]   
RewriteCond %{HTTP_REFERER} !^http://www.samool.com$ [NC]   
RewriteCond %{HTTP_REFERER} !^http://samool.com/.*$ [NC]   
RewriteCond %{HTTP_REFERER} !^http://samool.com$ [NC] 
RewriteRule .*\.(gif|jpg|mp3|rm|wma|exe|rar|zip)$ http://www.samool.com/403.html[R,NC]

请将以上内容保存为.htaccess文件,放在网站根目录,修改红色网址为你的网址,绿色为错误页面。

  1. 01phpgrace 定义json返回数据2020-03-06
  2. 02phpGrace 自带分页参数代码2020-03-05
  3. 03PHP检测Emoji过滤Emoji2020-03-01
  4. 04PHP对HTML标签转义及反转义2020-02-16
  5. 05PHP爬虫工具phpquery中文手册2020-02-16
  6. 06PHP爬虫采集工具phpQuery的用法2020-02-16
  7. 07(3种解决办法)获取微信公众号图片资源2020-02-16
  8. 08发现phpGrace工具实例化函数bug一枚2020-02-15
  9. 09宝塔面板apache配置静态文件缓存2020-02-01
  10. 10php字符串大小写转换2019-12-27
COMMENTS / 一纸留言

读者留言 0 条

一纸留言,便是山水间的一次相逢。

还没有留言,欢迎写下第一段交流。

WRITE A COMMENT

写下你的留言