Home  >  Article  >  Backend Development  >  How to remove index.php from apache

How to remove index.php from apache

王林
王林Original
2020-08-19 15:53:533445browse

apache去掉index.php的方法:首先打开httpd.conf配置文件,开启apache的url重写模式;然后修改配置【AllowOverride All】;最后创建并编辑【.htaccess】文件,将其放在项目根目录下即可。

How to remove index.php from apache

首先打开Apache配置文件httpd.conf,在该文件中去掉LoadModule rewrite_module modules/mod_rewrite.so前面的“#”号,即开启Apache的url重写模式。

(推荐教程:php图文教程

然后将httpd.conf文件里面的所有AllowOverride None都改为AllowOverride All。

接着创建.htaccess文件并将其放到项目根目录下。

在这个文件里面加如下内容:

(学习视频推荐:php视频教程

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php/$1 [L]

如果项目支持在配置文件中设置项目的url重写模式,需要在项目的配置文件里写:

return Array( 
‘URL_MODEL’ => ’2′, 
);

The above is the detailed content of How to remove index.php from apache. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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