Apache "Object Not Found!" URL“/error/*”

Apache "Object Not Found!" on URL "/error/*"

希望有人能帮我确定我的问题出在哪里。我有一个完整的 PHP 拼凑在一起的应用程序架构。在我尝试创建 URI 映射(以类似于 Slim Framework 的工作方式)之前,它一直运行良好。这是一个代码示例(尽管使用我在过去几年构建的类似于 CodeIgniter 的另一种架构也有同样的问题):

class Err extends Base_Director {
    function __construct() {

        /* THIS WORKS EITHER WAY! */
        $this->get('/', function(){
            echo 'Error.';
        });

        /* THIS WORKS VIA '/err/404' BUT NOT WHEN CLASS IS 'error' ('/error/404') */
        $this->get('/404', function(){
            echo 'Numeric Error 404.';
        });

        /* THIS WORK VIA '/err/four' BUT NOT WHEN CLASS IS 'error' ('/error/four') */
        $this->get('/four', function(){
            echo 'Alphanumeric Error.';
        });

        $this->submit();
    }
}

我真的认为这是 Apache 的问题,但谷歌搜索和搜索 Whosebug 没有找到任何有效的方法。似乎任何 URL 使用 $_GET 变量(带有 '/error/*')returns Apache 的 "Object not found!" 页面。页面内容如下:

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

然而,所有其他 URL 值都可以正常工作。

上次我试图解决这个不便时,我认为它可能是 Apache 中的保留关键字或其他东西,但我从来没有挖掘过 Web 服务器文件,担心我可能会搞砸。如果您认为我应该包含一些代码,请告诉我。顺便说一句,这是我正在使用的.htaccess

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{REQUEST_URI} !^(index\.php|\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ ./index.php?url= [NC,QSA,L]

更新: 我更多地研究了这个问题以帮助缩小范围。 "example.com/error/404" returns "Object Not Found!" 页面如上所述,但 "example.com/Error/404" 正常。

更新二: 这是我的 httpd 配置:

    DocumentRoot "C:/xampp/htdocs"
    <Directory "C:/xampp/htdocs">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks Includes ExecCGI
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   AllowOverride FileInfo AuthConfig Limit
        #
        AllowOverride All
     Order allow,deny
     Allow from all
        #
        # Controls who can get stuff from this server.
        #
        Require all granted
    </Directory>

不想淹没这个 post 所以可以在 PasteBin

上找到我的 httpd 文件的其余部分

将你写的全部替换成这个,它会做同样的事情,并且可能会解决你的问题:

DirectoryIndex index.php
RewriteEngine On

RewriteRule /error/(.*) /err/ [L,R=301]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule (.*) /index.php?url= [L]

特雷弗编辑: 在编辑 httpd-multilang-errordoc.conf 并注释掉 Alias /error/ "C:/xampp/apache/error/" 之后,我得到了上面的工作。也可以通过别名简单地更改错误重定向。这似乎是 Xampp 的一个特性,我对解决方案的添加可能不适用于其他服务器 "bundles"。