At Kunstmaan we use the websites we build with the Kunstmaan Bundles CMS mostly as a platform for running marketing and communication campaigns. To launch a campaign effectively on the radio for example it is important to use short urls for the landingpages. In the past we configured these via Apache RewriteRules in the Apache configuration or in a .htaccess file. This had some disadvantages, because every redirect needed both a technical intervention and a new deploy to the production environment.

So, we created a new bundle that adds a redirect configuration section in the administration interface. Since we already leveraged the awesome ChainRouter from the Symfony CMF project for our SlugRouter, we added a second router in the chain that uses the redirects configured in this section. We added it "after" the SlugRouter, so it's only possible to redirect origin urls that don't exist in the pages.

Installation

Add the new bundle to your composer.json file and run composer update

"kunstmaan/redirect-bundle": "2.3.*",

And to your AppKernel.php:

new Kunstmaan\RedirectBundle\KunstmaanRedirectBundle(),

Update your database:

app/console doctrine:schema:update --force

And you're done!

If you start a new project using the Bundles Standard Edition it will already be installed by default.