In order to track errorhandling I set the errordocuments in .htaccess to a script like so:
ErrorDocument 400 /catch
ErrorDocument 401 /catch
ErrorDocument 403 /catch
ErrorDocument 404 /catch
ErrorDocument 405 /catch
ErrorDocument 408 /catch
ErrorDocument 500 /catch
ErrorDocument 502 /catch
ErrorDocument 504 /catch
In the catch script I take the url that generated the error and write to db, before redirecting to /error. On the website there are numerous subdomains, each with their own catch and error page. However, I need all non existing subdomains to redirect to the catch of the main domain, without changing the url (nonexistingsubdomain.example.org becomes https://www.example.org/nonexistingsubdomain which should be catched by the catch script in which:
$url= (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
should read https://www.example.org/nonexistingsubdomain.
I have tried a couple of things, but none seem to work. I haven't been able to find a similar question as I allready use the errordocuments, and some subdomains do exist.