Chinaunix

标题: 关于apache防盗链的问题 [打印本页]

作者: 小小磊    时间: 2006-09-01 14:07
标题: 关于apache防盗链的问题
据个例子,我有2个站点,一个http://test1.test.net,另外一个http://test2.test.net

我想给test1站点加上防盗链,但是test2能够通过 http://test1.test.net/t e s t . j p g 这个的方式访问。


我是这么加的:

RewriteCond      %{HTTP_REFERER}                 !^http://*.test.net$          [NC]   
  RewriteRule      .*.(gif|jpg|jpeg|bmp|png)$       http://xxx.test.net            [R,NC]

加上以后,test2这个站点无法显示图片,请问这个表达式应该怎么写?
作者: 2020    时间: 2006-09-01 20:53
参考下面这个做修改
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?myhost.net /.*$ [NC]
RewriteRule \.(png|jpeg|gif|jpg)$  [F]

看见jackylau的回复,再回头看我的帖子才发现不慎多拷贝了个[img]进去 ,最后一行以jackylay的为准...sorry~

[ 本帖最后由 2020 于 2006-9-3 22:08 编辑 ]
作者: 小小磊    时间: 2006-09-01 23:53
谢谢楼上的。

还有个问题,就是我在ie浏览器直接输入http://test1.test.net/t e s t . j p g  还是能访问这个图片,有什么办法这样也不能访问么?
作者: jackylau    时间: 2006-09-03 15:32
RewriteRule \.(png|jpeg|gif|jpg)$  [NC] [F]
作者: itsea    时间: 2006-09-04 23:48
为什么我用这个脚本的时候报
.htaccess: Invalid command 'RewriteCond', perhaps mis-spelled or defined by a module not included in the server configuration
是否是用RewriteCond要在apache的conf文件里做设置?
作者: 小小磊    时间: 2006-09-05 11:35
回楼上的,我是在虚拟机的配置文件里面进行的修改…………
作者: jackylau    时间: 2006-09-08 13:16
原帖由 itsea 于 2006-9-4 23:48 发表
为什么我用这个脚本的时候报
.htaccess: Invalid command 'RewriteCond', perhaps mis-spelled or defined by a module not included in the server configuration
是否是用RewriteCond要在apache的conf文件里做 ...

看你的apache有没加载rewrite模块没?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2