url_strip_query_string

url

Removes all query parameters from a URL

Syntax

url_strip_query_string(url)

Parameters

url (string)

The URL string to modify

Returns

string

The URL without query parameters

Examples

Input:
url_strip_query_string("https://example.com?foo=bar&baz=qux")
Output:
"https://example.com"
Input:
url_strip_query_string("https://example.com/path?query=value#fragment")
Output:
"https://example.com/path#fragment"

The url_strip_query_string() function removes all query parameters from a URL, including the ”?” character and everything after it up to any fragment identifier.

Usage

Use url_strip_query_string() when you need to clean URLs by removing tracking parameters, session IDs, or other query strings, such as normalizing URLs for deduplication or creating clean canonical URLs.