I'll consolidate my comments to this answer:
When setting ...
ErrorDocument 404 /404.php
the /404.php
path may not be the absolute path to your htdocs folder root but instead the root of your filesystem. This may be, based on your configuration, e.g. /home/htdocs/
or ~
and so on.
So what one need to do is find out the absolute path and set it accordingly.
Where is your 404.php
actually located in relation to your .htaccess
file? Can you simply run it as a direct URL? Is the file readable by the server? Or is it in a nested subdirectory? You can also try the full URL as well:
ErrorDocument 404 http://mygreat.server/404.php
Full details in the official Apache documentation here.
You use ErrorDocument like so:
ErrorDocument <3-digit-code> <action>
The <3-digit-code>
is a HTTP response status code (eg. "404").
And you have three types of <action>
that are triggered by what you type:
For example:
Local path:
ErrorDocument 404 /local/path/to/404.php
External URL:
ErrorDocument 404 http://external_url.example.com/server_error.html
Custom text:
ErrorDocument 404 "Oops! We can't find that pesky file. Sorry."
You've chosen a local path, but are probably not pointing correctly to the file from the server's perspective. Note that local server paths are not what you see in your URL, and often include things like ~/htdocs/www/domainname/
.
The problem is most likely that your path to 404.php
is wrong, and cannot be found by your server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With