28

I know this thread has been talked a lot on the web and here, and I tried almost all the methods, but still I'm having the same problem.

This is my url on my local server ( MAMP )

http://localhost:8888/hellothere/index.php

And I've tried to insert a wrong path to take me to wrong page , like below :

http://localhost:8888/hellothere/eiurgiuerib

Instead of taking me to Error Page it shows :

Not Found

The requested URL /hellothere/eiurgiuerib was not found on this server.

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

My 404 page is inside of the Error directory. And inside my .htaccess file I have included this :

ErrorDocument 404 /Error/404.php
user1725155
  • 345
  • 1
  • 4
  • 11

2 Answers2

50

The ErrorDocument directive, when supplied a local URL path, expects the path to be fully qualified from the DocumentRoot. In your case, this means that the actual path to the ErrorDocument is

ErrorDocument 404 /hellothere/error/404page.html
StaticVariable
  • 5,253
  • 4
  • 23
  • 45
  • One more think , If in my index.php page I just add this line of code " header("HTTP/1.0 404 Not Found"); " It won't take me to 404 page, why is that ? – user1725155 Oct 06 '12 at 14:56
  • @user1725155 you should read this article [custom 404 not working](http://stackoverflow.com/questions/5914120/php-header-404-not-working) – StaticVariable Oct 06 '12 at 15:00
  • Many thanks, I was repeatedly trying to beat this into apache from the server root and not the document root. – dotParx Feb 08 '19 at 15:43
1

When we apply local url, ErrorDocument directive expect the full path from DocumentRoot. There fore,

 ErrorDocument 404 /yourfoldernames/errors/404.html
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
karthik k
  • 49
  • 3