url_set_domain_without_www

url

Removes "www." from the domain of a URL

Syntax

url_set_domain_without_www(url)

Parameters

url (string)

The URL string to modify

Returns

string

The URL with "www." removed from the domain

Examples

Input:
url_set_domain_without_www("https://www.example.com")
Output:
"https://example.com"
Input:
url_set_domain_without_www("https://www.example.com/path?query=value")
Output:
"https://example.com/path?query=value"

The url_set_domain_without_www() function removes the “www.” prefix from a URL’s domain if present, preserving all other URL components.

Usage

Use url_set_domain_without_www() when you need to normalize URLs by removing the “www.” prefix, which is useful for URL deduplication, canonical URL generation, or consistent domain formatting.