URI normalization explained

URI normalization is the process by which URIs are modified and standardized in a consistent manner. The goal of the normalization process is to transform a URI into a normalized URI so it is possible to determine if two syntactically different URIs may be equivalent.

Search engines employ URI normalization in order to correctly rank pages that may be found with multiple URIs, and to reduce indexing of duplicate pages. Web crawlers perform URI normalization in order to avoid crawling the same resource more than once. Web browsers may perform normalization to determine if a link has been visited or to determine if a page has been cached. Web servers may also perform normalization for many reasons (i.e. to be able to more easily intercept security risks coming from client requests, to use only one absolute file name for each resource stored in their caches, named in log files, etc.).

Normalization process

There are several types of normalization that may be performed. Some of them are always semantics preserving and some may not be.

Normalizations that preserve semantics

The following normalizations are described in RFC 3986 [1] to result in equivalent URIs:

<nowiki>http://example.com/foo%2a</nowiki><nowiki>http://example.com/foo%2A</nowiki>

<nowiki>HTTP://User@Example.COM/Foo</nowiki><nowiki>http://User@example.com/Foo</nowiki>

<nowiki>http://example.com/%7Efoo</nowiki><nowiki>http://example.com/~foo</nowiki>

<nowiki>http://example.com/foo/./bar/baz/../qux</nowiki><nowiki>http://example.com/foo/bar/qux</nowiki>

<nowiki>http://example.com</nowiki><nowiki>http://example.com/</nowiki>

<nowiki>http://example.com:80/</nowiki><nowiki>http://example.com/</nowiki>

Normalizations that usually preserve semantics

For http and https URIs, the following normalizations listed in RFC 3986 may result in equivalent URIs, but are not guaranteed to by the standards:

<nowiki>http://example.com/foo</nowiki><nowiki>http://example.com/foo/</nowiki>

However, there is no way to know if a URI path component represents a directory or not. RFC 3986 notes that if the former URI redirects to the latter URI, then that is an indication that they are equivalent.

Normalizations that change semantics

Applying the following normalizations result in a semantically different URI although it may refer to the same resource:

<nowiki>http://example.com/a/index.html</nowiki><nowiki>http://example.com/a/</nowiki>

<nowiki>http://example.com/default.asp</nowiki><nowiki>http://example.com/</nowiki>

<nowiki>http://example.com/bar.html#section1</nowiki><nowiki>http://example.com/bar.html</nowiki>

However, AJAX applications frequently use the value in the fragment.

<nowiki>http://208.77.188.166/</nowiki><nowiki>http://example.com/</nowiki>

The reverse replacement is rarely safe due to virtual web servers.

<nowiki>https://example.com/</nowiki><nowiki>http://example.com/</nowiki>

<nowiki>http://example.com/foo//bar.html</nowiki><nowiki>http://example.com/foo/bar.html</nowiki>

<nowiki>http://www.example.com/</nowiki><nowiki>http://example.com/</nowiki>

<nowiki>http://example.com/display?lang=en&article=fred</nowiki><nowiki>http://example.com/display?article=fred&lang=en</nowiki>

However, the order of parameters in a URI may be significant (this is not defined by the standard) and a web server may allow the same variable to appear multiple times.[9]

<nowiki>http://example.com/display?id=123&fakefoo=fakebar</nowiki><nowiki>http://example.com/display?id=123</nowiki>

Note that a parameter without a value is not necessarily an unused parameter.

<nowiki>http://example.com/display?id=&sort=ascending</nowiki><nowiki>http://example.com/display</nowiki>

<nowiki>http://example.com/display?</nowiki><nowiki>http://example.com/display</nowiki>

Normalization based on URI lists

Some normalization rules may be developed for specific websites by examining URI lists obtained from previous crawls or web server logs. For example, if the URI

<nowiki>http://example.com/story?id=xyz</nowiki>appears in a crawl log several times along with

<nowiki>http://example.com/story_xyz</nowiki>we may assume that the two URIs are equivalent and can be normalized to one of the URI forms.

Schonfeld et al. (2006) present a heuristic called DustBuster for detecting DUST (different URIs with similar text) rules that can be applied to URI lists. They showed that once the correct DUST rules were found and applied with a normalization algorithm, they were able to find up to 68% of the redundant URIs in a URI list.

See also

References

Notes and References

  1. https://tools.ietf.org/html/rfc3986#section-6 RFC 3986, Section 6. Normalization and Comparison
  2. https://tools.ietf.org/html/rfc3986#section-6.2.2.1 RFC 3986, Section 6.2.2.1. Case Normalization
  3. https://tools.ietf.org/html/rfc3986#section-6.2.2.1 RFC 3986, Section 6.2.2.1. Case Normalization
  4. https://tools.ietf.org/html/rfc3986#section-6.2.2.2 RFC 3986, Section 6.2.2.3. Path Segment Normalization
  5. https://tools.ietf.org/html/rfc3986#section-5.2.4 RFC 3986, 5.2.4. Remove Dot Segments
  6. https://tools.ietf.org/html/rfc3986#section-6.2.2.3 RFC 3986, 6.2.2.3. Path Segment Normalization
  7. https://tools.ietf.org/html/rfc3986#section-6.2.3 RFC 3986, Section 6.2.3. Scheme-Based Normalization
  8. https://tools.ietf.org/html/rfc3986#section-6.2.3 RFC 3986, Section 6.2.3. Scheme-Based Normalization
  9. Web site: jQuery 1.4 $.param demystified . Ben Alman . 2009-12-20 . 2013-08-24.