删除CI ubuntu 12.04中的index.php文件

时间:2013-04-01 07:37:29

标签: php .htaccess codeigniter mod-rewrite

我想从CI中的文件路径中删除index.php文件。我使用的是ubuntu 12.04。我尝试了几乎所有的论坛结果,但没有成功。

我将CI文件夹放在此路径中。

http://localhost/xxx/CI/

我有apache重写mod启用。

sudo a2enmod rewrite
Module rewrite already enabled

我的conf.php文件中也有这个

$config['uri_protocol'] = 'AUTO';
$config['base_url'] = 'http://localhost/xxx/CI/'; 
$config['index_page'] = '';
$config['index_url'] = '';

我在.htaccess文件中有这个

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

.htaccess文件位于此路径

http://localhost/xxx/CI/.htaccess

也可以通过apache启用

/etc/apache2/sites-available/default
AllowOverride All

当我像这样访问文件时,我收到此错误

 http://localhost/xxx/CI/login/
 404 Error
 The requested URL /xxx/CI/login/ was not found on this server.

任何帮助将不胜感激。

由于

3 个答案:

答案 0 :(得分:3)

尝试使用以下.htaccess文件:

RewriteEngine On
RewriteBase /xxx/CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]

然后,将uri_protocolAUTO更改为PATH_INFO

$config['uri_protocol'] = 'PATH_INFO';

如果开始将所有内容重新路由到默认控制器,则将其更改为ORIG_PATH_INFO

$config['uri_protocol'] = 'ORIG_PATH_INFO';

其他信息

将这些行插入您的文件中:

Options -Multiviews +FollowSymLinks
AllowOverride All

答案 1 :(得分:1)

尝试以下:

RewriteEngine On
RewriteBase /xxx/CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder/index.php/$1 [L]

并且必须启用apache的“rewrite_module”。

配置中的

和index_page应为空 $ config ['index_page'] ='';

答案 2 :(得分:0)

您的htaccess文件中是否有此代码

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
相关问题