薛伟 发表于 2011-9-26 16:17:17

删除index.php

在论坛中看了好多如何删除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,再此先谢谢了,大侠们!!!

Ben 发表于 2011-9-26 16:35:26

你的问题解决方法是,首先你要把你的config.php文件中

$config['base_url']        = 'http://你的网址/';

然后

$config['index_page'] = 'index.php'; 换成 $config['index_page'] = '';

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

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1        
</IfModule>

然后就OK了

薛伟 发表于 2011-9-26 17:03:55

谢了,这样做后,好像加不加index.php都可以访问,是么?

zkyy66 发表于 2012-3-6 12:03:55

Ben 发表于 2011-9-26 16:35 static/image/common/back.gif
你的问题解决方法是,首先你要把你的config.php文件中




我按照你的,没成功,加上<IfModule mod_rewrite.c>就报错

Altair 发表于 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 static/image/common/back.gif
你的问题解决方法是,首先你要把你的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          
</IfModule>
复制代码

nop2 发表于 2013-4-21 18:18:12

一个完全被问烂了的问题:L
页: [1]
查看完整版本: 删除index.php