PHPackages                             palmtree/canonical-url-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. palmtree/canonical-url-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

palmtree/canonical-url-bundle
=============================

Canonical URL Symfony bundle

v1.1.0(6y ago)23961MITPHPPHP &gt;=5.6

Since Mar 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/palmtreephp/canonical-url-bundle)[ Packagist](https://packagist.org/packages/palmtree/canonical-url-bundle)[ RSS](/packages/palmtree-canonical-url-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (16)Used By (0)

Canonical Url Bundle
====================

[](#canonical-url-bundle)

[![License](https://camo.githubusercontent.com/d3cfb2bca34811e61d93bea80f13749e7e8e40a0a6630867ae08ab7654d6865c/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70616c6d747265652f63616e6f6e6963616c2d75726c2d62756e646c652e737667)](LICENSE)[![Travis](https://camo.githubusercontent.com/48d68bb19033585e92ffcb1cb2f635d74e421690ea585d0a3670013997972617/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f70616c6d747265657068702f63616e6f6e6963616c2d75726c2d62756e646c652e737667)](https://travis-ci.org/palmtreephp/canonical-url-bundle)[![Scrutinizer](https://camo.githubusercontent.com/89ad8abed98e02ef1b0e61fbe0d0f732ecc9ccc85c2d6a5182055d5fae487fdc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70616c6d747265657068702f63616e6f6e6963616c2d75726c2d62756e646c652e737667)](https://scrutinizer-ci.com/g/palmtreephp/canonical-url-bundle/)[![Scrutinizer Coverage](https://camo.githubusercontent.com/569931fd3445dce617545afef24f561a008a224a89f6c5266cad800f770b3008/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f70616c6d747265657068702f63616e6f6e6963616c2d75726c2d62756e646c652e737667)](https://scrutinizer-ci.com/g/palmtreephp/canonical-url-bundle/)

The `CanonicalUrlBundle` is a Symfony bundle to redirect requests from multiple URLs for the same resource to a single canonical URL.

For example, if you had a resource named /about-us for your site example.org it could potentially be accessed with:

```
http://example.org/about-us
http://example.org/about-us/
http://www.example.org/about-us
http://www.example.org/about-us/
https://example.org/about-us
https://example.org/about-us/
https://www.example.org/about-us
https://www.example.org/about-us/

```

When a user requests the resource with any of the above URLs, `CanonicalUrlBundle` will build a canonical URL based on a predefined site URL and will perform an HTTP redirect to it if the request URL does not match.

The bundle can also add a `` tag to your twig templates, see the [Usage](#usage) section for how.

Installation
------------

[](#installation)

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
composer require palmtree/canonical-url-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `app/AppKernel.php` file of your project:

```
