2010-07-08 267 views
0

在我的htaccess文件中,我的ErrorDocument 404語句沒有重定向到index.php。相反,我得到一個常規的404錯誤。這是一個常規的Apache安裝。404重定向不起作用

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    #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 
    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

可憐的你!我真的希望你能理清這一點 – 2010-07-08 15:46:06

+0

你正在使用哪種瀏覽器來測試它? – Sjoerd 2010-07-08 15:48:06

+0

你知道你是否啓用了mod_rewrite(你可以用'echo phpinfo()')來檢查嗎?此外,你是什麼意思的「正規404」。你的意思是Apache的404或CI的? – 2010-07-08 15:49:21

回答

0

我得到它排序。我使用Code Igniter中的自定義錯誤處理路由器並跳過.htaccess文件。我沒有直接訪問客戶端服務器,所以我自己做了更改,併爲他們提供了CI的標準.htaccess文件。這讓我的生活變得更簡單。

0

需要更多信息在這裏。獲得CodeIgniter的404或Apache的404?

如果你得到CodeIgniter的404,它按預期工作。

+0

我得到了apache的404 – 2010-07-14 22:17:14

+0

你正在重定向到/index.php,但是index.php在哪裏?在文檔根目錄?或者你在一個子文件夾中工作? – Zack 2010-07-17 15:09:54