CI(4)隐藏URL里面的index.php过程总结
2017-03-03 10:42
411 查看
1、开启apache重定向功能:
(1)要修改Apache 的配置文件,让Apache支持rewrite_module,修改过程如下:打开apache的配置文,conf/httpd.conf
:LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉;
(2)搜索 AllowOverride None 即 Options Indexes FollowSymLinks MultiViews下面那个,修改为 AllowOverride All (一般情况下是有两个,两个都要修改!)。
2、项目的根目录(与index.php文件是同一级目录)下新建一个.htaccess文件,并写入如下内容:
RewriteEngine on
RewriteBase /ci/project //注意这里面的/ci/project/表示的是项目名称的(apache配置项目时的目录名称)
RewriteCond $1 !^(index\.php|images|robots\.txt) //对于样式、JS、静态元素是不能rewrite的所以加这一句
RewriteRule ^(.*)$ index.php/$1 [L]
或:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ci/project/index.php/$1 [L]
3、修改CI框架下的‘/application/config/config.php’配置文件:
$config['index_page']
= "index.php"; 修改为 $config['index_page'] = "";
实例:
初始访问“helloworld”页面链接:localhost/ci/project/index.php/helloworld
修改后访问链接:localhost/ci/project/helloworld
(1)要修改Apache 的配置文件,让Apache支持rewrite_module,修改过程如下:打开apache的配置文,conf/httpd.conf
:LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉;
(2)搜索 AllowOverride None 即 Options Indexes FollowSymLinks MultiViews下面那个,修改为 AllowOverride All (一般情况下是有两个,两个都要修改!)。
2、项目的根目录(与index.php文件是同一级目录)下新建一个.htaccess文件,并写入如下内容:
RewriteEngine on
RewriteBase /ci/project //注意这里面的/ci/project/表示的是项目名称的(apache配置项目时的目录名称)
RewriteCond $1 !^(index\.php|images|robots\.txt) //对于样式、JS、静态元素是不能rewrite的所以加这一句
RewriteRule ^(.*)$ index.php/$1 [L]
或:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ci/project/index.php/$1 [L]
3、修改CI框架下的‘/application/config/config.php’配置文件:
$config['index_page']
= "index.php"; 修改为 $config['index_page'] = "";
实例:
初始访问“helloworld”页面链接:localhost/ci/project/index.php/helloworld
修改后访问链接:localhost/ci/project/helloworld
相关文章推荐
- CI框架 .htaccess 隐藏url在index.php解决方案
- CI框架 .htaccess 隐藏url中index.php的解决(转)
- 教你如何在CI框架中使用 .htaccess 隐藏url中index.php
- CI框架 .htaccess 隐藏url中index.php的解决
- CI框架 .htaccess 隐藏url在index.php解决方案
- 教你如何在CI框架中使用 .htaccess 隐藏url中index.php
- 教大家怎样去除codeIgniter开发的网站url里面的index.php字符串
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- 隐藏CodeIgniter程序URL中index.php的方法
- CI如何隐藏index.php
- CI去掉 URL 中的 index.php
- Codeigniter(CI) 去掉 URL 中的 index.php
- CI 框架去除URL上的index.php 来直接访问
- CI框架如何删除URL中index.php的终极解决方案
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- CI 框架(Apache环境)有效删除URL中的index.php
- 去掉php框架CI默认url中的index.php【整理】
- 去掉php框架CI默认url中的index.php
- CI框架如何删除URL中index.php的终极解决方案
- 如何去除codeIgniter开发的网站url里面的index.php字符串