Home >Operation and Maintenance >Apache >How to configure to prohibit access to files other than index.php file
配置禁止访问index.php文件以外的文件的方法:1、新建【.htaccess】文件,增加重写规则;2、编辑httpd.conf文件,支持重写模块;3、重启apache服务。
在apache中web目录下,新建index.php,other.php 可以发现都可以访问。
(推荐教程:apache教程)
在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
相关推荐: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!