因為有些目錄希望只有特定的IP可以存取的到。
所以有這個需求。
下面這個目錄的原始設定

<Directory "C:\\web\\aaaacccc\\">

       AddDefaultCharset UTF-8
       Options Indexes FollowSymLinks Includes ExecCGI
       AllowOverride All
       Require all granted
       Order Allow,Deny
       Allow from all

</Directory>

這樣的設定是誰都可以讀取。

<Directory "C:\\web\\aaaacccc\\">

       AddDefaultCharset UTF-8
       Options Indexes FollowSymLinks Includes ExecCGI
       AllowOverride All
       Require all granted
       Order Allow,Deny
       Allow from 192.168.1.1

</Directory>

這樣修改後,就變成只有這個 192.168.1.1 可以連進去。但是可以在進一步設定加上 ErrorDocument 403

<Directory "C:\\web\\aaaacccc\\">

       AddDefaultCharset UTF-8
       Options Indexes FollowSymLinks Includes ExecCGI
       AllowOverride All
       Require all granted
       Order Allow,Deny
       Allow from 192.168.1.1
      
ErrorDocument 403 http://tw.yahoo.com

</Directory>

這樣子只要連到這個目錄下的位置,只要ip不對,就會被轉向yahoo,連403

arrow
arrow
    文章標籤
    apache ip allow erro
    全站熱搜

    阿基 發表在 痞客邦 留言(1) 人氣()