apache的簡單配置

一、需求:將 http://localhost/ 的請求所有轉向 http://localhost/demo/html

測試環境:wamplinux

錯誤解決:windows

http.conf文件末尾加上ide

Alias / "/demo/"測試

<Directory "/demo/">spa

Options Indexeshtm

Order Allow, Denyget

Allow from allit

</Directory>io

正確方法:

Alias / "E:/wamp/www/demo/"

<Directory "E:/wamp/www/demo/">

Options Indexes

Order Allow, Deny

Allow from all

</Directory>

錯誤分析:linux支持相對路徑,windows需用絕對路徑

二、FollowSymlinks的使用

Options Indexes, FollowSymlinks 在linux下就有權限訪問目錄下的連接文件,windows下的連接文件訪問時後綴爲.ln 訪問時出現亂碼

三、如何阻止文件被訪問

/

  hello.html

  static

     hello.html

      js

         hello.html

         hello.htm

問題一:因此的hello.html 都不可被訪問

              <Files "hello.html">

                       Order Deny,Allow(注:deny與allow之間不得有空格,不然wamp出錯)

                       Deny from all

              </Files>

 

問題二:只有根目錄下的helo.html可以被訪問

Alias / "E:/wamp/www/demo/"

<Directory "E:/wamp/www/demo/">

Options Indexes

Order Allow, Deny

Allow from all

           <Files "hello.html">

                       Order Deny,Allow(注:deny與allow之間不得有空格,不然wamp出錯)

                       Deny from all

              </Files>

</Directory>

這樣配置,windows下仍然是因此的hello.html都沒法訪問,linux下未測試,老師測試成功

三、static下的hello.html不可訪問

四、js目錄下的hello.htm不可訪問(用FilesMatch實現)

相關文章
相關標籤/搜索