How to remove index.php in php in ci

藏色散人
Release: 2023-03-02 19:30:02
Original
2968 people have browsed it

ci中php去除index.php的方法:首先打开apache的配置文件;然后去除“modules/mod_rewrite.so”前面的“#”符号;接着在CI的根目录下建立“.htaccess”;最后重启apache即可。

How to remove index.php in php in ci

CI框架去除index.php

打开apache的配置文件,conf/httpd.conf :

LoadModule rewrite_module modules/mod_rewrite.so
Copy after login

把该行前的#去掉。

搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为:

AllowOverride All
Copy after login

在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):

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

如果不在根目录下:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /目录/index.php/$1 [L]
Copy after login

将CI中配置文件(application/config/config.php)中

$config['index_page'] = "index.php";
Copy after login

改成:

$config['index_page'] = "";
Copy after login

重启apache,完成。

相关推荐:《PHP教程

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

Related labels:
ci
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