apache怎么配置禁止访问index.php以外的php文件

2025-09-11 22:18:13

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

apache怎么配置禁止访问index.php以外的php文件

apache怎么配置禁止访问index.php以外的php文件

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

RewriteEngine on

 

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

3、

修改http.conf,支持rewrite_module:

LoadModule rewrite_module modules/mod_rewrite.so

apache怎么配置禁止访问index.php以外的php文件

4、修改http.conf,修改AllowOverride None 为 AllowOverride All,配置文件中有多个AllowOverride,请注意AllowOverride的上下文。

apache怎么配置禁止访问index.php以外的php文件

apache怎么配置禁止访问index.php以外的php文件

5、重启apache:

/usr/local/httpd/bin/apachectl restart

使用浏览器访问other.php

apache怎么配置禁止访问index.php以外的php文件

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢