robustness / flexibility: treat 'staging.domain' and 'domain:nnn' (port number) the same as 'domain'. Also don't replace 'www.' in the middle of a domain name.