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

[HELP] 删除index.php

[复制链接]
发表于 2011-9-26 16:17:17 | 显示全部楼层 |阅读模式
在论坛中看了好多如何删除index.php的方法,如http://codeigniter.org.cn/forums/thread-4-1-2.html,以及如何更改apache配置以支持rewrite模块,如http://dancewithnet.com/2010/05/29/making-mod-rewrite-and-htaccess-work-on-mac-os-x/,在我的机器上怎么就是不行啊,郁闷了,怎么配置到最后,运行时总是提示
Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request.
但apache的htdocs下的其他php文件运行正常,我用的是apache2.2版本,有谁成功了,详细介绍下如何配置,从apache到CI,再此先谢谢了,大侠们!!!
发表于 2011-9-26 16:35:26 | 显示全部楼层
你的问题解决方法是,首先你要把你的config.php文件中

PHP复制代码
$config['base_url']     = 'http://你的网址/';
复制代码


然后

PHP复制代码
$config['index_page'] = 'index.php'; 换成 $config['index_page'] = '';
复制代码


接着在根目录下.htaccess,中写

PHP复制代码
<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php/$1 [L]         
</IfModule>
复制代码


然后就OK了
 楼主| 发表于 2011-9-26 17:03:55 | 显示全部楼层
谢了,这样做后,好像加不加index.php都可以访问,是么?
发表于 2012-3-6 12:03:55 | 显示全部楼层
Ben 发表于 2011-9-26 16:35
你的问题解决方法是,首先你要把你的config.php文件中

我按照你的,没成功,加上<IfModule mod_rewrite.c>就报错
发表于 2013-2-6 00:14:19 | 显示全部楼层
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-3-10 20:41:03 | 显示全部楼层
Ben 发表于 2011-9-26 16:35
你的问题解决方法是,首先你要把你的config.php文件中

我按照这个做,成功了。。。
发表于 2013-4-21 14:56:31 | 显示全部楼层
热水只需一建:
借鉴:
PHP复制代码
<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php/$1 [L]         
</IfModule>
复制代码
发表于 2013-4-21 18:18:12 | 显示全部楼层
一个完全被问烂了的问题

本版积分规则