diff --git a/docs/guide/runtime-routing.md b/docs/guide/runtime-routing.md index 3671755da2..bc521380d8 100644 --- a/docs/guide/runtime-routing.md +++ b/docs/guide/runtime-routing.md @@ -519,15 +519,17 @@ contains a customized URL rule which uses `.json` as its suffix instead of the g ### URL normalization -Since version 2.0.10 [[yii\web\UrlManager|UrlManager]] uses [[yii\web\UrlNormalizer|UrlNormalizer]] for dealing +Since version 2.0.10 [[yii\web\UrlManager|UrlManager]] can be configured to use [[yii\web\UrlNormalizer|UrlNormalizer]] for dealing with variations of the same URL with and without trailing slash. Because technically `http://example.com/path` and `http://example.com/path/` are different URLs, serving the same content for both of them can degrade SEO. By default normalizer collapses consecutive slashes, adds or removes trailing slashes depending on whether the -suffix has a trailing slash or not, and redirects to normalized version of URL using [permanent redirection](https://en.wikipedia.org/wiki/HTTP_301). -Normalizer can be configured individually for URL manager and each rule - by default rule will use normalizer +suffix has a trailing slash or not, and redirects to the normalized version of the URL using [permanent redirection](https://en.wikipedia.org/wiki/HTTP_301). +The normalizer can be configured globally for the URL manager or individually for each rule - by default each rule will use the normalizer from URL manager. You can set [[yii\web\UrlRule::$normalizer|UrlRule::$normalizer]] to `false` to disable normalization for particular URL rule. +The following shows an example configuration for the UrlNormalizer: + ```php [ 'components' => [ diff --git a/framework/web/UrlManager.php b/framework/web/UrlManager.php index 86dc997b1a..da6859b12e 100644 --- a/framework/web/UrlManager.php +++ b/framework/web/UrlManager.php @@ -132,7 +132,7 @@ class UrlManager extends Component * If you wish to enable URL normalization, you should configure this property manually. * For example: * - * ``` + * ```php * [ * 'class' => 'yii\web\UrlNormalizer', * 'collapseSlashes' => true,