I have a file index.php
, and in the same level a .htaccess
with this code:
ErrorDocument 404 index.php
When i generate a not found error is printed a page with the name of the file, so, in this case i only see index.php
as literal text. What i want is obviously a redirect to the homepage.
Any idea about this problem?
www\site
-index.php
-.htaccess
You want:
ErrorDocument 404 /index.php
In the ErrorDocument docs:
URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser. Examples:
ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 /subscription_info.html
ErrorDocument 403 "Sorry can't allow you access today"
So if it's not a FQDN or something that starts with a /
, it is assumed that you want a customized message to be displayed.
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