2013-10-19 50 views
0

我想刪除index.php,在我的本地主機,但它似乎不工作,它的http://localhost/testing刪除本地codeigniter index.php

我把.htacces放在htdocs下的'testing'目錄下。

LoadModule rewrite_module modules/mod_rewrite.so 在Apache/conf上也沒有選中。

這裏我的.htaccess:

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

這裏我的配置:

$config['base_url'] = "http://localhost/testing"; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

當我訪問登錄控制器,它沒有找到。

未找到

所請求的網址/測試/登錄此服務器上未找到。

我真的不知道接下來要做什麼。任何幫助,將不勝感激。

+0

有沒有其他設置? –

回答

0

基本的index.php包含在所有的網址:

,我們可以使用.htaccess文件用一個簡單的規則刪除此。下面是此類文件的一個例子,使用「負」的方法中,一切都被重定向,

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

立即重新啓動服務器,並檢查

+0

感謝您的答案,我嘗試了,但它仍然無法工作 –

0

htaccess應該像

RewriteEngine On 
RewriteBase /testing/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

沒有必要追加/testing/,因爲RewriteBase已經處理好了。

+0

感謝您的答案,我嘗試了,但它仍然無法工作 –

+0

@AldiAryanto將'base_url'設置爲'http:// localhost /' 。 –

+0

仍然不能正常工作:( –

1

試試這個: -

的config.php: -

$config['base_url'] = 'http://localhost/testing/'; 

$config['index_page'] = ''; 

的.htaccess

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

謝謝你的回答,我嘗試了,但它仍然不能工作 –

0

留出RewriteBase結尾的斜線:

RewriteEngine On 
RewriteBase /testing 

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

$config['base_url']應該是http://localhost/testing/

$config['index_page']應該是空白的。

0

試試這個.htaccess文件中: 「?」

RewriteEngine on 
RewriteCond $1 !^(index\.php|robots\.txt|resources) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L] 
ErrorDocument 404 /mainpage 

您的配置文件是好的

區別在於指數後。php

0

您可能還想嘗試更改./application/config/config.php中的$config[‘uri_protocol’]的值。有時CodeIgniter會錯誤的。將其更改爲PATH_INFO可能有效。