I want to use a custom error page for ALL errors, so that there is no possible way that a visitor will see the servers built in error pages. But I seem to have found a glitch that I can not overcome.
The problem is that should a visitor mistype a URL with only spaces between two slashes, my environment seems to completely ignore my root folder htaccess file and sends the user to the built in error page.
The development environment is XAMPP on Windows 10. with the latest PHP & Apache etc.
To simplify the problem to it's root I am now using this HTACCESS File.
ErrorDocument 404 /statuspage.php
RewriteEngine On
RewriteRule ^ http://example.com [R=302,L]
The above code should redirect any and all URLs to example dot com. If that fails on not found pages, it should at least redirect to my error page. (which would probably then be caught and sent to example.com anyway.)
But when I type any of the following URLs, my entire project is ignored including the HTACCESS file and XAMPP throws out its own 404 error page.
1) www.mysite.com/ /
2) www.mysite.com/ /file.php
3) www.mysite.com/dir/%20/subdir/file.html
Apache replaces the space with %20. Ignores my redirect. And displays its own 404 page.
I should note that THESE errors are redirected just fine.
1) www.mysite.com/ file.php/ 2) www.mysite.com/dir/ x/file.html
I realize this error would not be common. But it can happen and I'm struggling to understand what is happening and how to stop it.