Thanks very much.
I apologize for making you do all the writing - although it does not hurt to hear from Jim - and bookmark it.
I tested several sites on different servers (hosting providers), and on first two I got this (which caused me to react with Aaaa... 500):
You don't have permission to access / on this server.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
On some other servers it states nicely 403 on the top.
Obviously, the code worked fine for 403, but then failed on custom 403.
This is what I have in my .htaccess:
ErrorDocument 404 /error-404.php
ErrorDocument 403 /error-403.php
And the code in 403 PHP file is this:
header('Status: 403 Forbidden', null, 403);
$from_header = "From: firstname.lastname@example.org\r\n";
$to = "email@example.com";
$subject = "403 Error";
$today = date("D M j Y g:i:s a T");
$ip = getenv ("REMOTE_ADDR");
$requri = getenv ("REQUEST_URI");
$servname = getenv ("SERVER_NAME");
$pageload = $ip . " tried to load ["
...] . $servname . $requri ;
$httpagent = getenv ("HTTP_USER_AGENT");
$httpref = getenv ("HTTP_REFERER");
$message = "$today \n\n$pageload \n\nUser Agent = $httpagent \n\n$httpref ";
mail($to, $subject, $message, $from_header);
The reality is that I do get emails caused by 403
. Do I get all, I don't know at this moment, I have to pull the logs and count errors and compare to emails I got.
Anyway, when it says 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request
- does this mean it failed at reading the line in .htaccess or when it attempted to execute PHP code?