[linux 2019-07-09] apache配置防盗链

1.检查是否安装 mod_rewrite 模块

apachectl -t -D DUMP_MEDULES |grep rewrite

2.安装 mod_rewrite 模块 (若已安装,则跳过)

#http解压目录
./configure --prefix=/usr/local/httpd --enable-rewrite --enable-so --enable-charset-lite --enable-cgi
make && make install

3.配置 mod_rewrite 模块启用

vim httpd.conf

<Directory "/usr/local/httpd/htdcos">
    ...
    Order allow,deny
    Allow from all

    #以下为添加内容
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://shijt.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://shijt.com/$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.shijt.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.shijt.com/$ [NC]
    RewriteRule .*\.(gif|jpg|swf)$ http://www.shijt.com/error.png

</Directory>

4.再次执行第1步代码,检查模块是否安装

5.重启httpd服务

效果如图:

 

转载于:https://www.cnblogs.com/shijt/p/11160897.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值