What is the SuluRedirectBundle?
As a developer, you probably recognize this situation: you need to add some redirects you got from a content manager via email to an nginx redirects file, create a pull request, wait until that has been merged, and then redeploy the whole website just for a few new redirects to be applied. That’s a long process, especially if the content manager could simply do that by themselves. And that’s the challenge the SuluRedirectBundle solves.
This bundle adds simple but powerful capabilities for managing redirects to Sulu’s administration interface and allows content managers to manage redirects without any knowledge of web servers.
Just bear in mind that a redirect is only taken into account if no page or article with the same URL exists, because redirects have the lowest priority in the system.
One of the great features of this bundle is the ability to import redirects from a CSV file. The most simplified file just contains two columns, “source” and “target”. Of course, all the other options like “statusCode”, “sourceHost”, and “enabled” can also be set in the import file.
It’s also possible to override existing redirects with an import; you just have to set the same value for “source”.
Enabling and disabling redirects
Sometimes it’s necessary to prepare redirects which are not ready yet, especially if you have a large number of redirects. Of course there’s a solution for that — toggler in the toolbar to enable or disable redirects quickly. This allows you to import a large number of disabled redirects and then check them in the administration interface, before enabling them when needed.
The SuluRedirectBundle comes with three different statuses to be used for redirects:
- 301 Moved permanently
- 302 Moved temporarily
- 410 Gone
Each of them is useful in different situations, but I think they are quite self explanatory.