CodeIgniter - 删除index.php

时间:2011-03-05 11:42:08

标签: codeigniter

我在CI安装中删除index.php时遇到了一些问题,目前使用的.htaccess如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule> 

我的CI安装是从public_html目录返回的,我已将配置更改为

$config['index_page'] = "";

所以我的CI看起来如下

/core-1.7.3
/public_html/index.php

当我输入网址时,我得到了404,但是当我把index.php放在它前面时,它运行正常:S

我很困惑

4 个答案:

答案 0 :(得分:0)

也尝试改变这个:

$config['uri_protocol'] = “REQUEST_URI” 

答案 1 :(得分:0)

您好 我安装了1.7.3,这个.htaccess使用了这个URL -

/CodeIgniter_1.7.3/public_html/welcome

.htaccess-&GT;

RewriteEngine On

RewriteCond $1 !^(index\.php|resources|robots\.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

答案 2 :(得分:0)

通过Avisek Chakraborty的评论,确保你已经完成了所有这些,但是 听起来像你没有正确安装mod_rewrite。 确保使用以下测试: http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

它是为Windows编写的,但你应该明白这一点。

如果不起作用,请安装mod_rewrite并重试。

答案 3 :(得分:0)

您需要针对.htaccess的FollowSymLinks指令重写...

Options Indexes FollowSymLinks

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

Options指令位于The Apache Docs