3

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

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

http://localhost/xxx/CI/

我有 apache rewrite mod enable 。

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.

任何帮助将不胜感激 。

谢谢

4

3 回答 3

3

尝试使用以下.htaccess文件:

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

然后,将您的uri_protocolfrom更改AUTOPATH_INFO

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

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

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

附加信息

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

Options -Multiviews +FollowSymLinks
AllowOverride All
于 2013-04-01T08:42:07.467 回答
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'] = '';

于 2013-04-01T07:45:43.303 回答
0

您的 htaccess 文件中有此代码吗

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
于 2013-04-01T07:43:20.387 回答