My current js formula removes http://, https://, www and anything after ‘/’.
function cleanUrl(url) {
return url.replace(/^(http(s)?:\/\/)?(www\.)?/gi,"");
}
E.G:
http://www.google.com/piza
returns google.com
How can I do remove everything but the domain in one step but with PHP?
Use
parse_url().Do note that http://www.example.com and example.com are technically entirely separate entities that can point at totally different sets of records.