Home > Operation and Maintenance > Apache > How to configure to prohibit access to files other than index.php file

How to configure to prohibit access to files other than index.php file

王林
Release: 2020-10-21 16:22:49
Original
3152 people have browsed it

配置禁止访问index.php文件以外的文件的方法:1、新建【.htaccess】文件,增加重写规则;2、编辑httpd.conf文件,支持重写模块;3、重启apache服务。

How to configure to prohibit access to files other than index.php file

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

(推荐教程:apache教程

How to configure to prohibit access to files other than index.php file

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

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

修改http.conf,支持rewrite_module:

LoadModule rewrite_module modules/mod_rewrite.so
Copy after login

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

重启apache:

/usr/local/httpd/bin/apachectl restart
Copy after login

相关推荐:php培训

The above is the detailed content of How to configure to prohibit access to files other than index.php file. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template