Reputation: 322
I have a custom 404 page called 404page.php , and I have the htaccess file with the line that I found should work (this is the only line I have in the .htaccess file)
ErrorDocument 404 /404page.php
It was working fine yesterday, but today I was optimizing images and some other stuff on the website, and when I reuploaded it, the htaccess didn't redirect to 404page.php anymore, but to a page that has this written:
Not Found
The requested URL /asfsdtg was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
(I just typed asfsdtg to test if it was working).
The website is uploaded online and I'm managing it through cpanel (I'm still a beginner). I searched for some solutions, I tried adding another line to .htaccess, then it looked like this:
RewriteEngine on
ErrorDocument 404 /404page.php
I even tried putting the location of the 404page.php as a local link, and the internet link, and it still gave me the weird error page.
Does anyone have some idea whats happening? If you need more info that I didn't supply please tell me what more I can supply
Upvotes: 6
Views: 25671
Reputation: 11
ErrorDocument 404 /404page.php
If above setting does not works you have to write addition line of code as mentions below. Which identifies for non existing files and directories and redirect to 404.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ - [R=404,L]
Upvotes: 0
Reputation: 410
Try out this:
RewriteEngine on
ErrorDocument 404 http://yoursitename.com/404page.php
And be sure that 404page.php
exists on the root of your server and is trully called 404page.php
not 404Page.php
Be carefull at the characters, this is key sensitive!
Upvotes: 13
Reputation: 127
Try with like this:
RewriteEngine on
ErrorDocument 404 http://www.sitename.com/404.php
Upvotes: 1