Apache .htaccess文件找不到404 ErrorDocument

Apache .htaccess文件找不到404 ErrorDocument,apache,.htaccess,xampp,http-status-code-404,Apache,.htaccess,Xampp,Http Status Code 404,我拥有的.htaccess文件在名为error的子文件夹中找不到我的404.html文档。特别是: ErrorDocument 404/error/404.html 但是,如果我将404.html放在与.htaccess相同的目录中,并将行更改为: ErrorDocument 404/404.html-It-works 如果有帮助的话,我正在使用XAMPP for Windows,在我的httpd.conf文件中,相关指令设置如下,我意识到存在一些冗余: <Directory />

我拥有的.htaccess文件在名为error的子文件夹中找不到我的404.html文档。特别是:

ErrorDocument 404/error/404.html

但是,如果我将404.html放在与.htaccess相同的目录中,并将行更改为:

ErrorDocument 404/404.html-It-works

如果有帮助的话,我正在使用XAMPP for Windows,在我的httpd.conf文件中,相关指令设置如下,我意识到存在一些冗余:

<Directory />
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

<Directory "C:/xampp/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI MultiViews
    AllowOverride All
    Require all granted
</Directory>
哦,还有最后一件值得一提的事——我正在使用虚拟主机。以下是相关信息:

<VirtualHost *>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ServerAlias localhost
    <Directory "C:/xampp/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost flchi.local>
    DocumentRoot "C:/xampp/htdocs/sites/flchi"
    ServerName flchi.local
    ServerAlias flchi.local
    <Directory "C:/xampp/htdocs/sites/flchi">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

发生这种情况是因为命名冲突-默认Apache配置已经为/error定义了虚拟路径,全局影响所有虚拟主机。它在配置文件xampp/apache/conf/extra/httpd-multilang-errordoc.conf中完成。位置/错误,因此阴影显示/error子目录:

  Alias /error/ "C:/xampp/apache/error/"
如果您将“error”子目录重命名为其他目录(例如error2),它应该可以工作


发生这种情况是因为命名冲突-默认Apache配置已经为/error定义了虚拟路径,全局影响所有虚拟主机。它在配置文件xampp/apache/conf/extra/httpd-multilang-errordoc.conf中完成。位置/错误,因此阴影显示/error子目录:

  Alias /error/ "C:/xampp/apache/error/"
如果您将“error”子目录重命名为其他目录(例如error2),它应该可以工作


您试图使用的404.html文件的绝对路径是什么?您的.htaccess在哪个目录下?404.html:C:/xampp/htdocs/sites/flchi/error/404.html的绝对路径。.htaccess所在的目录是:/flchi。您试图使用的文件404.html的绝对路径是什么?您的.htaccess在哪个目录中?404.html的绝对路径是:C:/xampp/htdocs/sites/flchi/error/404.html。.htaccess所在的目录是:/flchi.Bingo,就是它!我将目录更改为站点错误,一切正常!谢谢宾果,就是这样!我将目录更改为站点错误,一切正常!谢谢
   ErrorDocument 404 /error2/404.html