Use $_SERVER['HTTP_HOST']

… instead of trying to determine if the port needs to be appended