如何配置禁止访问index.php文件以外的文件

来自:网络
时间:2020-10-21
阅读:

如何配置禁止访问index.php文件以外的文件

在apache中web目录下,新建index.php,other.php 可以发现都可以访问。

如何配置禁止访问index.php文件以外的文件

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

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
返回顶部
顶部