Windows下rewrite 技术实现 Apache 防盗链
时间:2010-12-31 来源:秩名
apache 防盗链的第一种实现方法,可以用 rewrite 实现。首先要确认 apache 的 rewrite module 可用:能够控制 apache httpd.conf 文件的,打开 httpd.conf,确保有这么一行配置:
代码如下:
loadmodule rewrite_module modules/mod_rewrite.so 在找到自己网站对应的 配置的地方,加入下列代码:
代码如下:
servername hackline.net
# 防盗链配置
rewriteengine on
rewritecond %{http_referer} !^http://hackline.net/.*$ [nc]
rewritecond %{http_referer} !^http://hackline.net$ [nc]
rewritecond %{http_referer} !^http://www.hackline.net/.*$ [nc]
rewritecond %{http_referer} !^http://www.hackline.net$ [nc]
rewritecond %{http_referer} !^http://www.baidu.com$ [nc]
rewritecond %{http_referer} !^http://www.google.com$ [nc]
rewritecond %{http_referer} !^http://www.google.com.hk$ [nc]
rewriterule .*.(gif|jpg|swf)$ http://www.hackline.net/about/nolink.png [r,nc]
标签分类: