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

[HELP] CodeIgniter去掉index.php失败

[复制链接]
发表于 2012-7-16 20:16:13 | 显示全部楼层 |阅读模式
  1. http://localhost/ci_demo/index.php/welcome
复制代码


1. 打开apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉。
搜索 AllowOverride None 即 Options Indexes FollowSymLinks MultiViews下面那个,修改为 AllowOverride All

2. 在index.php,system的同级目录下,建立.htaccess,先建立记事本文件,另存为该名的文件。内容如下
  1. RewriteEngine on  
  2. RewriteCond $1 !^(index\.php|images|robots\.txt)  
  3. RewriteRule ^(.*)$ /[color=red]ci_demo[/color]/index.php/$1 [L]
复制代码

因为我的目录是www/ci_demo,红色标注

3.然后将config.php中的 $config['index_page' = '';

为什么最后还是不能去掉.php? 求解。


 楼主| 发表于 2012-7-16 20:26:07 | 显示全部楼层
硬是不行,这是为什么{:soso_e130:}
发表于 2013-1-20 21:36:25 | 显示全部楼层
2、//开启 .htaccess
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

我的是在<Directory />
</Directory>下有这段
发表于 2013-1-20 22:27:47 | 显示全部楼层
1:htaccess
2:config.php
3:router.php
发表于 2013-1-21 09:26:19 | 显示全部楼层
别人帮你回答,你也要帮助别人
发表于 2013-2-6 00:04:47 | 显示全部楼层
如何删除url中index-php的终极解决方案
发表于 2013-2-6 00:05:59 | 显示全部楼层
如何删除URL中index.php的终极解决方案
发表于 2013-2-6 00:13:03 | 显示全部楼层
http://www.crazyfriday.net/2013/02/%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4url%E4%B8%ADindex-php%E7%9A%84%E7%BB%88%E6%9E%81%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/   如何删除URL中index.php的终极解决方案
发表于 2013-8-30 16:08:38 | 显示全部楼层
如果你的项目是通过虚拟主机配置的:

1)确认apache httpd.conf中已经开启rewrite模块(无#代表已开启)

  LoadModule rewrite_module libexec/mod_rewrite.so
  
2)确认apache httpd-vhost.conf中DocumentRoot有访问权限,假设我的根目录是:"D:/xampp/htdocs/CodeIgniter"
   
   DocumentRoot "D:/xampp/htdocs/CodeIgniter"
   ServerName http://codeigniter.test.com  -->url中要访问的域名
   <Directory "D:/xampp/htdocs/CodeIgniter">
        Options +Indexes +FollowSymLinks
        AllowOverride All -->不能是None,否则会报404
                Order allow,deny
                Allow from All -->不能是Deny from all,否则会报无权访问
    </Directory>
   
3)在如上根目录下建立.htacess文件,加入如下配置:

   <IfModule mod_rewrite.c>

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ /index.php/$1 [QSA,PT,L]

   </IfModule>
   4)重启apache ,开始测试吧。如:http://codeigniter.test.com/News/index

   5)说明:第2中的修改与httpd.conf文件无关,httpd.conf无须做任何更改。
           无需修改config.php中$config['index_page'] = 'index.php';
           此做法如果输入http://codeigniter.test.com/index.php/News/index也能访问,不过已经能实现去除index.php了。

本版积分规则