404 page not showing

2019-03-03 15:48发布

问题:

I have a 404 page on a static site on my localhost(MAMP) setup. The file is called 404.html (at the root of the site) and in my .htacccess file (at the root of the site) I have placed the following line of code:

ErrorDocument 404 /404.html

However the 404.html page doesn't show when I type an incorrect URL. I've done a test to confirm the 404.html page does show though when doing mysite/404.html.

Does anyone know what the problem could be?

Thanks

回答1:

I had a similar problem once and for me it was a misconfigured httpd.conf, maybe that can fix it for you:

The file is located at MAMP_Root\apache\conf\httpd.conf.
In my file there was a ErrorDocument 404 "/cgi-bin/missing_handler.pl" line and I just needed to comment it out to fix the problem.

Also can you please post your full .htaccess file, it could contain other stuff that interferes (I'd add this as a comment but I don't have enough rep, sorry).