7_Apache 配置 之rewrite 限制

來源:互聯網
上載者:User

標籤: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 限制

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.