Home  >  Article  >  Backend Development  >  How to remove index.php from CI framework?

How to remove index.php from CI framework?

青灯夜游
青灯夜游Original
2020-11-06 15:19:321802browse

方法:1、配置apache的httpd.conf文件;2、在CI根目录下,建立并配置“.htaccess”文件;3、打开config.php文件,查找“$config['index_page']”项,将其中的值改为空;4、重启apache。

How to remove index.php from CI framework?

推荐:《PHP视频教程

一、apache

1、打开apache的配置文件,conf/httpd.conf,搜索如下内容,去掉改行前的#

LoadModule rewrite_module modules/mod_rewrite.so

2、还是在conf/httpd.conf文件中搜索AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为:

AllowOverride All

二、CI框架

1、在CI的根目录下,在system的同级目录下,建立.htaccess文件,写入如下内容:

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|phpMyAdmin|robots\.txt) 
RewriteRule ^(.*)$ /index.php?/$1 [L]

第二行是不进行重定向的文件。

2、打开项目目录中的application/config/config.php,查找$config['index_page'] = "index.php";修改为:

$config['index_page'] = "";

三、重启apache,完成。

更多编程相关知识,请访问:编程视频!!

The above is the detailed content of How to remove index.php from CI framework?. 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