2013-04-01 41 views
3

我想從CI中的文件路徑中刪除index.php文件。我使用的是Ubuntu 12.04。我嘗試了幾乎所有的論壇結果,但沒有成功。刪除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 

它也可以通過帕什

/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. 

任何幫助將不勝感激。

感謝

+0

您是否收到了404錯誤?你的'.htaccess'文件位於哪裏? –

+0

是的麥克我得到404錯誤。我的.htaccess文件位於此路徑 http:// localhost/xxx/CI /。htaccess的 – Uahmed

回答

3

嘗試使用下面的.htaccess文件:

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

然後,你uri_protocolAUTOPATH_INFO改變:

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

如果啓動重新路由一切默認的控制器,然後改變它到ORIG_PATH_INFO

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

其他信息

插入這些行到您的文件:

Options -Multiviews +FollowSymLinks 
AllowOverride All 
+0

我真的很感激你的回覆,我完全按照你的說法做了,但仍然沒有工作,給我404錯誤。首先我改變uri_protocol到PATH_INFO它表明我404錯誤比我改變它再次ORIG_PATH_INFO它給我的404錯誤:( – Uahmed

+0

請看看我的修正答案。(附加信息) –

+0

我有這個早些時候在這個文件 的/ etc /的Apache2 /網站可用/默認 選項指標多視圖的FollowSymLinks 的AllowOverride所有 我改變這個根據你的消息還是404錯誤,我重新啓動Apache的了。 – Uahmed

0

你有這樣的代碼在你的htaccess文件

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

我試過了,但仍然相同 – Uahmed

1

如下嘗試:

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

並檢查阿帕奇 「rewrite_module」 必須啓用。

和你的配置中的index_page應該是空的 $ config ['index_page'] ='';

+0

我試過,但它沒有工作,是已啓用的Apache rewrite_module過,這是真的太$配置[「的index.php」] =「」; – Uahmed

+0

我RewriteBase /無功/網絡/ XXX/CI/ – Uahmed

+0

它應該是「XXX/CI /」 –