如何配置禁止訪問index.php文件以外的文件

配置禁止訪問index.php文件以外的文件的方法:1、新建【.htaccess】文件,增加重寫規則;2、編輯httpd.conf文件,支持重寫模塊;3、重啟apache服務。

如何配置禁止訪問index.php文件以外的文件

在apache中web目錄下,新建index.php,other.php 可以發現都可以訪問。

(推薦教程:apache教程

如何配置禁止訪問index.php文件以外的文件

在web目錄下新建文件(.htaccess),加入以下內容:

立即學習PHP免費學習筆記(深入)”;

RewriteEngine?on RewriteRule?^(.*)$?index.php/$1?[L]

修改http.conf,支持rewrite_module:

LoadModule?rewrite_module?modules/mod_rewrite.so

修改http.conf,修改AllowOverride None 為 AllowOverride All,配置文件中有多個AllowOverride,請注意AllowOverride的上下文。

重啟apache:

/usr/local/httpd/bin/apachectl?restart

相關推薦:apache教程

? 版權聲明
THE END
喜歡就支持一下吧
點贊5 分享