Syntax based normalization of URL's

1.4.0 2015-06-11 16:06 UTC

This package is not auto-updated.

Last update: 2023-12-05 12:27:45 UTC


This normalizes URI's based on the specification RFC 3986

Example usage

require_once 'vendor/autoload.php';

$url = 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d';
$un = new URL\Normalizer( $url );
echo $un->normalize();

// Result: 'example://a/b/c/%7Bfoo%7D'

The normalization process preserves semantics

So, for example, the following URL's are all equivalent.

  • HTTP:// and
  • and
  • and
  • and
  • and
  • and
  •[key]=value and

Normalizations performed

  1. Converting the scheme and host to lower case
  2. Capitalizing letters in escape sequences
  3. Decoding percent-encoded octets of unreserved characters
  4. Adding trailing /
  5. Removing the default port
  6. Removing dot-segments

For more information about these normalizations, please see the following Wikipedia article:

For license information, please see LICENSE file.


Two options are available when normalizing URLs which are disabled by default:

  1. Remove empty delimiters. Enabling this option would normalize to Currently, only the query string delimiter (?) is supported by this option.
  2. Sort query parameters. Enabling this option sorts the query parameters by key alphabetically. For example, becomes


Add further scheme-based normalization steps, as detailed in section 6.2.3 of the RFC.