Skip to main content

GenericUrlNormalizer

Generic implementation that should satisfy most URL normalization needs.

Notesโ€‹

Normalizes crawled URLs to reduce duplicate content caused by equivalent URLs that differ only in format. Supports built-in normalization rules (such as lowercasing the scheme and host, removing default ports, and encoding non-URI characters) and custom search-and-replace patterns.

Examplesโ€‹

The following adds a normalization to add www. to URL domains when missing, to the default set of normalizations. It also add custom URL "search-and-replace" to remove any &view=print strings from URLs as well as replace &type=summary with &type=full.

class: GenericUrlNormalizer
normalizations:
- REMOVE_FRAGMENT
- LOWERCASE_SCHEME_HOST
- UPPERCASE_ESCAPESEQUENCE
- DECODE_UNRESERVED_CHARACTERS
- REMOVE_DEFAULT_PORT
- ENCODE_NON_URI_CHARACTERS
- ADD_WWW
replacements:
- match: "&view=print"
value: ""
- match: (&type=)(summary)
value: $1full

Usageโ€‹

Full configuration skeleton, with every option and its default
class: GenericUrlNormalizer
normalizations:
- ADD_DIRECTORY_TRAILING_SLASH
replacements:
- match: string
value: string

Propertiesโ€‹

PropertyTypeRequiredDefault
normalizationsenum[]No[REMOVE_FRAGMENT, LOWERCASE_SCHEME_HOST, UPPERCASE_ESCAPESEQUENCE, DECODE_UNRESERVED_CHARACTERS, REMOVE_DEFAULT_PORT, ENCODE_NON_URI_CHARACTERS]
replacementsNormalizationReplace[]No-

Property Detailsโ€‹

normalizationsโ€‹

URL normalization rules. Rules prefixed with an asterisk (*) preserve semantic equivalence, as per the RFC 3986 standard.

replacementsโ€‹

Replace one or more matching portions of URLs with different text.