404重定向无效

时间:2010-07-08 15:45:10

标签: .htaccess codeigniter http-status-code-404

在我的htaccess文件中,我的ErrorDocument 404语句没有重定向到index.php。相反,我得到一个常规的404错误。这是一个常规的apache安装。

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

2 个答案:

答案 0 :(得分:0)

此处需要更多信息。获得CodeIgniter的404或Apache的404?

如果您获得了CodeIgniter的404,那么它正在按预期工作。

答案 1 :(得分:0)

我把它分类了。我在Code Igniter中使用了自定义错误处理路由器并跳过了.htaccess文件。我没有直接访问客户端服务器,因此我自己进行了更改,并为CI提供了标准的.htaccess文件。它让我的生活变得更加简单。