Home Non existing subdomain error handling using php and .htaccess
Reply: 0

Non existing subdomain error handling using php and .htaccess

user1189 Published in June 25, 2018, 8:02 am

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.34426 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO