PHP CI(CodeIgniter) 如何去掉url中的index.php

此生再无相见时 提交于 2020-02-26 11:14:34

1、打开Apache配置文件httpd.conf,找到

1 #LoadModule rewrite_module modules/mod_rewrite.so

去掉前面的#

 

搜索AllowOverride,将相应Directory下的AllowOverride设置为All

1 AllowOverride All

 

2、在CI的根目录下,建立.htaccess文件,文件内容如下

 1 RewriteEngine On  
 2 
 3 RewriteCond %{REQUEST_URI} ^system.*  
 4 RewriteRule ^(.*)$ /index.php?/$1 [L] 
 5 
 6 RewriteCond %{REQUEST_URI} ^application.*  
 7 RewriteRule ^(.*)$ /index.php?/$1 [L]  
 8 
 9 RewriteCond %{REQUEST_FILENAME} !-f  
10 RewriteCond %{REQUEST_FILENAME} !-d  
11 RewriteRule ^(.*)$ index.php?/$1 [L]

 

3、打开文件application/config/config.php,$config['index_page'] = "index.php";改为$config['index_page'] = "";

1 $config['index_page'] = ""; 

 

4、重启Apache

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!