标签:配置防盗链 访问控制Directory 访问控制FilesMatch
一、防盗链配置vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
配置文件增加如下内容
<Directory /data/wwwroot/123.com>
SetEnvIfNoCase Referer "http://www.123.com" local_ref
SetEnvIfNoCase Referer "http://123.com" local_ref
SetEnvIfNoCase Referer "^$" local_ref
<filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
Order Allow,Deny
Allow from env=local_ref
</filesmatch>
</Directory>
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
curl -e "http://www.baidu.com/123.html" -x127.0.0.1:80 www.123.com/images/123.jpg -I
curl -e "http://www.123.com/123.html" -x127.0.0.1:80 www.123.com/images/123.jpg -I
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
核心配置文件内容
<Directory /data/wwwroot/123.com/images/>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
curl -x127.0.0.1:80 www.123.com/images/123.jpg -I
在本机浏览器测试
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
核心配置文件内容
<Directory /data/wwwroot/123.com>
<FilesMatch admin.php>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</FilesMatch>
</Directory>
在浏览器测试123.com下其他文件可以打开,admin.php无法访问
curl -x127.0.0.1:80 www.123.com/admin.php -I
43.防盗链配置、访问控制Directory、访问控制FilesMatch
标签:配置防盗链 访问控制Directory 访问控制FilesMatch
原文地址:http://blog.51cto.com/13569831/2104662