2011-11-10 170 views
0

因此,我花了幾個小時。我想不明白。我讀過幾個留言板,但沒有成功。從Codeigniter網站刪除index.php

這裏是我做了什麼:

1) 增加了一個名爲 「htaccess的」 文件夾 「/ WWW/SITE_NAME」 文件。 該文件包含以下內容:

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

2) 改變

$config['index_page'] = 'index.php'; 

$config['index_page'] = ''; 

3) 經歷了幾個文件httpd.conf中改變線的每一個可能的組合:

AllowOverride None 

AllowOverride All 

4) 啓用rewrite_module

這是推動我絕對瘋了。我在這上面花了幾個小時。

編輯: 也許我沒有設置正確的AllowOverride所有。哪一個是正確的?編輯: 我得到它的工作。感謝您選擇的幫助

+0

您是否重新啓動了Apache,因爲安裝了mod重寫? –

+0

是的。每次更改後我都會重新啓動。 – swl1020

+0

運行服務器的平臺是什麼? Windows,Mac或Linux? –

回答

1

下面是我在codeigniter安裝中使用的.htaccess文件。也許你可以嘗試一下,試圖排除.htaccess文件?如果這有效,那麼我們可以添加其他規則,如果他們真的需要你的情況?

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    #RewriteBase/

    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    RewriteCond %{REQUEST_URI} ^application.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?baseurl=$1 [QSA,L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

以下散裝線滿足您的需求,讓喜歡/images/和文件等的robots.txt等目錄如果文件或文件夾是否存在,它不會被改寫。應用程序和系統目錄受其他規則的保護。

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
+0

所以,我現在肯定在正確的軌道上。我的htaccess文件只包含我列出的內容。它不完全像你的。 但是。 現在,如果我去localhost/mysite,它會將我帶到家中的網站,這是正確的。 但如果我去localhost/mysite/faq(它存在),它將我帶到localhost主頁 – swl1020

+0

我得到它的工作。我不得不將rewritebase更改爲/ mysite – swl1020