2011-07-02 163 views
1

我開始了codeigniter網站。我的默認控制器是$ route ['default_controller'] =「login」;在routes.phpcodeigniter 404錯誤

和我的基地址是$ config ['base_url'] ='http://digimed.net/sandbox/';在config.php中

場景A 我在URL欄中輸入http://digimed.net/sandbox/我按預期得到了登錄控制器的索引方法。

方案B 我鍵入類似http://digimed.net/sandbox/login我得到一個404錯誤,當我預期的結果相同情景A.

事實上,我不能在登錄控制器訪問任何功能。我每次都會收到404錯誤。

有什麼我需要改變路線或congig?

感謝

+0

有你設置的重寫網絡服務器的規則? –

+0

uhm,不是特別沒有。我怎麼做? –

+0

嘗試將您的瀏覽器指向http://digimed.net/sandbox/index.php/login,如果它的作用不如此,則表示您錯過了重寫規則,請參閱Kevin的答案 –

回答

0

的情況下,任何人有興趣我解決了在網站路線目錄添加以下.htaccess文件(該笨的路線目錄的生活在哪裏)的問題

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /system_admin 

#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#'system' can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php/$1 [L] 

#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn't true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
#This last condition enables access to the images and css folders, and the robots.txt file 
#Submitted by Michael Radlmaier (mradlmaier) 
RewriteCond $1 !^(index\.php|images|robots\.txt|css) 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 
</IfModule> 
+0

如果這是解決方案,請將其標記爲被接受! – cwallenpoole

+0

@Kevin什麼是給RewriteBase的system_admin?我的網站的網址與subdomain.example.com相似,並且這些文件放在我的根文件夾中。如果是這樣,那麼RewriteBase應該是什麼? –

+0

@NaveedS我不知道如何使用RewriteBase作爲子域名,但在我的情況下,我用它來標記我的安裝爲example.com/system_admin。我的文件位於example.com目錄中名爲system_admin的文件夾中 –