25 12
发新话题
打印

去掉index.php的问题

本主题由 Hex 于 2008-2-15 18:08 移动

去掉index.php的问题

我用
RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|images|robots\.txt|files)
RewriteRule ^(.*)$ /index.php/$1 [L]
是把index.php后面的.php去掉了, 但是.  访问的时候还是要http://localhost/ci/index/welcome才可以,我的虚拟目录是/ci/有什么解决办法呢.

TOP

怎么会有这个问题呢?还真没有遇到过。
你修改 config.php 里的 $config['index_page'] = "index.php" 了吗?把 index.php 改成空试试。
QQ: 49489680
MSN: zhaochang_tj AT hotmail DOT com

TOP

已经试过了

已经试过了, 还是不行, 不知道为什么.

TOP

确实是有点怪

因为.htaccess中的内容都已经是指向了index.php中了.

TOP

.htaccess

.htaccess应该没啥问题呢. http://localhost/ci/user应该也会被重定向到index.php/user呢,但是不知道为什么就是没有生效

TOP

好奇怪,windows下是可以的

好奇怪的, 在windows下试了一下是可以的,但是在我的ub下就是不行。

TOP

rewriterule 写错了

路径是 /ci/index.php 不是index.php
Fred Wu
thislab.com

TOP

我已经加rewritebase了。

我已经加rewritebase指定了基本路径了。

TOP

rewritebase 起作用了吗?我还没用过 rewritebase,呵呵。
QQ: 49489680
MSN: zhaochang_tj AT hotmail DOT com

TOP

我也碰见这个问题了,我的操作. 编写下面代码到 .htaccess  文件,放到index.php同目录下.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

http://localhost/index.php/welcome 去掉index.php ,不行.

修改config.php文件里的$config['index_page'] = "";为空,测试也不行.

why?


------------------------------------------------------------
已经解决,谢谢大家!

[ 本帖最后由 chaing 于 2008-2-1 01:52 编辑 ]

TOP

你应该把 APACHE 的设置发上来看看!这东西和 CI 关系不大。
QQ: 49489680
MSN: zhaochang_tj AT hotmail DOT com

TOP

我有些问题和这差不多,url rewrite是成功了,但是访问下级目录时也会转到index.php上,请问这怎么改,让它对下级目录文件不转到index.php上呢

TOP

不是有个 RewriteCond $1 !^(index\.php|images|robots\.txt)  吗?看看 rewrite 规则,这是判断条件,符合的才 rewrite。前面的 ! 表示非。
QQ: 49489680
MSN: zhaochang_tj AT hotmail DOT com

TOP

你确定你的.htaccess功能打开了?

AllowOverride All

TOP

我把上面的综合了一下:
  一.在Apache中修改:
  1.加载rewrite.so
  2.修改为AllowOverride All
  
  二.在网站中对应index.php的目录中加入.htaccess文件:
  写入:
  RewriteEngine on
  Options FollowSymLinks
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ /ci/index.php/$1 [L]
  
  第四行表示在CI目录中,如果在网站的根目录中,则为RewriteRule ^(.*)$ /index.php/$1 [L]
  
  三.在CI的application/config/config.php中
  将$config['index_page'] = "index.php";改为$config['index_page'] = "";

TOP

 25 12
发新话题