Nginx 禁止訪問某個目錄或文件的設置方法_Web服務器教程

      編輯Tag賺U幣

      如果基于WEB根目錄下,要禁止用戶訪問/config目錄,或者要禁止用戶訪問/config.ini(ZF常用INI,不過建議還是放到WEB目錄以外的地方),可以通過location進行配置,返回403或者404等


      location = /config/ {
      return 404;
      }
      location =/config.ini{
      return 404;
      }


      這樣只能禁止訪問 http://www.wf0088.com/path/


      location = /path/ {
      return 404;
      }


      禁止訪問 http://www.wf0088.com/path/test.php


      location ^~ /test
      {
      deny all;
      }


      可能test要換成path.
      這樣就搞定了

      來源:網絡搜集//所屬分類:Web服務器教程/更新時間:2011-12-08
      相關Web服務器教程