Search code examples
apache.htaccesshttp-status-code-404

Xampp Error "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."


Hi I am trying out apache htaccess for my site(not wordpress). I want to make custom 404 error so I add following in .htaccess file:

ErrorDocument 404 /404.php

My file structure is

/htdocs
       /some-dir
                /.htaccess
                /404.php

while I accessing any random URL I get the error:

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Solution

  • ErrorDocument 404 /404.php
    

    The ErrorDocument directive takes a document root-relative URL-path, so from your file structure this should presumably be:

    ErrorDocument 404 /some-dir/404.php
    

    Reference: