thinkphp如何禁止直接通過路徑訪問?

來源:互聯網
上載者:User
現在很多的許可權系統是基於URL路由來控制的(模組 / 動作)比如thinkphp,訪問路徑是http://localhost/thinkphp/index.php/index/index 但是根據檔案路徑也能訪問到如http://localhost/thinkphp/Tpl/Index/index.html,就直接顯示了index.html的源碼!居然沒有解析,如何禁止訪問呢?或者其他的保護措施

回複內容:

現在很多的許可權系統是基於URL路由來控制的(模組 / 動作)比如thinkphp,訪問路徑是http://localhost/thinkphp/index.php/index/index 但是根據檔案路徑也能訪問到如http://localhost/thinkphp/Tpl/Index/index.html,就直接顯示了index.html的源碼!居然沒有解析,如何禁止訪問呢?或者其他的保護措施

放到Web目錄之外

http://doc.thinkphp.cn/manual/deploy_directory.html

建立一個public檔案夾,把入口檔案放到public中

如果有upload或者images檔案夾,也要放到puclib下

然後修改一下入口檔案中的目錄定義

// 定義應用目錄define('APP_PATH','../Application/');// 引入ThinkPHP入口檔案require '../ThinkPHP/ThinkPHP.php';
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.