用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1295|回复: 3
收起左侧

[版本 3.x] CI3.0 去URL中index.php 遇迷离问题,求帮忙!

[复制链接]
发表于 2016-6-6 18:57:39 | 显示全部楼层 |阅读模式
本帖最后由 JoeV587 于 2016-6-6 19:13 编辑

在网上查询了好多方法,都不能用,哪位大神弄过,帮忙告诉下,
环境windows,apache
采用什么方法修改呢。这是网上的方法
————————————————————————————————————————
然后,在 CI 根目录下新建立一个配置文件,命名为: .htaccess
在里面这样写:
  • RewriteEngine on
  • RewriteCond $1 !^(index\.php|images|robots\.txt)
  • RewriteRule ^(.*)$ /index.php/$1 [L]

就可以去掉 index.php 了。要注意 /index.php/$1 要根据你目录(Web 目录,比如 http://www.domain.com/index.php)的实际情况来定,比如网站根目录是 /ci/index.php 则要写成 /ci/index.php/$1
  • RewriteCond $1 !^(index\.php|images|robots\.txt)
  • $config['index_page' = "index.php";
  • 改为$config['index_page' = "";
————————————————————————————————————————

这样修改完以后还是不行,目录会出现
http://localhost/srgk//home/znst_index
必须加一个问号才行例如:
http://localhost/srgk/?/home/znst_index 这样才能访问通

谁知道,帮忙告诉下,多谢了



 楼主| 发表于 2016-6-6 19:13:09 | 显示全部楼层
有谁改过index.php ,帮忙指导下,多谢了~
 楼主| 发表于 2016-6-6 19:13:58 | 显示全部楼层
这样修改完以后还是不行,目录会出现
http://localhost/srgk//home/znst_index
必须加一个问号才行例如:
http://localhost/srgk/?/home/znst_index 这样才能访问通
谁知道,帮忙告诉下,多谢了
发表于 2016-6-7 09:45:29 | 显示全部楼层
  1. <IfModule mod_rewrite.c>
  2.     RewriteEngine On
  3.    RewriteBase /srgk/
  4.     RewriteCond %{REQUEST_FILENAME} !-f
  5.     RewriteCond %{REQUEST_FILENAME} !-d
  6.     RewriteRule ^(.*)$ index.php/$1 [L]
  7. </IfModule>

  8. <IfModule !mod_rewrite.c>
  9.     ErrorDocument 404 /index.php
  10. </IfModule>
复制代码

本版积分规则