標籤:rewrite 限制
有些目錄是使用者不需要訪問的
例如:
[[email protected] ~]# cd /data/www
[[email protected] www]# mkdir tmp/
[[email protected] www]# cd tmp/
[[email protected] tmp]# ls
[[email protected] tmp]# vim 12.txt
650) this.width=650;" src="http://s4.51cto.com/wyfs02/M01/88/4D/wKiom1fuE8zC4og7AACrXCoxML8182.jpg" title="dis24.jpg" alt="wKiom1fuE8zC4og7AACrXCoxML8182.jpg" />
此時的檔案 /data/www/tmp/12.txt 是可以正常訪問的。
現在我有一個需求,這個檔案夾內有一些重要檔案,不希望給使用者看到。
還是這個模組,注意紅色字型部份
[[email protected] ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
<IfModule mod_rewrite.c>
ReWriteEngine on
ReWriteCond %{HTTP_HOST} ^www.aaa.com$ [or]
ReWriteCond %{HTTP_HOST} ^www.bbb.com$
ReWriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]
# ReWriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC,OR] #NC 的意思是不區分大小,下同
ReWriteCond %{HTTP_USER_AGENT} ^.*chrome* [NC]
ReWriteRule .* - [F]
ReWriteCond %{REQUEST_URI} ^.*/tmp/.* [NC]
ReWriteRule .* - [F]
[[email protected] ~]# apachectl -t
Syntax OK
[[email protected] ~]# apachectl restart
再次訪問網站,網站403 ,禁止訪問。
http://www.test.com/tmp/12.txt
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/88/4E/wKiom1fuG72Cwl1FAADTi7DWr2Q148.jpg" title="dis25.jpg" alt="wKiom1fuG72Cwl1FAADTi7DWr2Q148.jpg" />
本文出自 “CBO#Boy_Linux之路” 部落格,請務必保留此出處http://20151213start.blog.51cto.com/9472657/1858145
7_Apache 配置 之rewrite 限制