首页 > 编程 > PHP > 正文

CI(4)隐藏URL里面的index.php过程总结

2019-11-06 08:19:55
字体:
来源:转载
供稿:网友
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 onRewriteBase /ci/PRoject  //注意这里面的/ci/project/表示的是项目名称的(apache配置项目时的目录名称)RewriteCond $1 !^(index/.php|images|robots/.txt) //对于样式、JS、静态元素是不能rewrite的所以加这一句RewriteRule ^(.*)$ index.php/$1 [L]或:RewriteEngine onRewriteCond $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
上一篇:php null

下一篇:thinkphp事务处理

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表