When I check the logs there are a few rare occasions where for some visitors(bot I think) the $_SERVER['HTTP_HOST']
is returning: www.domain.co.uk:80
What is the correct way to get only the domain name without any ports?
Should I be doing it this way instead:
$url_components = parse_url($_SERVER['HTTP_HOST']);
$domain = $url_components['host'];
The strange thing is that I cant replicate this behavior it only appears in the logs.
In this case $_SERVER['SERVER_NAME']
is your friend.
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