When migrating a website from another framework to SilverStripe, or even just rebuilding a website from scratch, often, a CMS editor likes to redirect a visitor from a landing page with an easy to remember URL to a page somewhere else in the site tree. In cases like these RedirectorPages are there for you, but are not always the best solution. Especially if you have a lot of pages to redirect to, cluttering your SiteTree with RedirectorPages is not really a good option.
And what about extra URL parameters you might want to push to your analytics?
It’s a common thing for CMS editors to encounter. Of course the software engineers can do this programmatically, but there are limits when it comes to customising those redirections.
Solution?
SilverStripe Redirected URLs
SilverStripe’s own module this time. Redirected URLs. This module makes it easy for CMS editors to redirect old pages to the new site’s structure and page. And its usage is very straight forward!
As usual installation is best done via composer:
composer require silverstripe/redirectedurls
Usage
After installation a new ModelAdmin, named Redirects, shows up in the CMS with a cross-over arrow image. In this ModelAdmin the CMS editors can create their own redirects when needed
As you can see there are two “from” options and one “to” option. The second “from” option might look a bit weird to you, but it is actually very useful. It’s the so called Querystring. Sometimes when you visit a website, you can see the URL being something similar to: https://domain.com/pages/?page=3&subpage=4. The bit after the question mark are called query variables or get variables (depending on who you ask). PHP can use those variables to decide what it should show. In this example, it could be the fourth child page of page number 3.
Now to rewrite that to a SilverStripe structure, this would translate to the page “about-us/contribution-open-source”, when using the silverstripe.com website as an example.
But query strings can contain anything from page information to search queries (you can see that when you do a search in Google), and CMS editors might want to translate those parameters to get users to visit a specific page.
Once you get the hang of it, it’s pretty simple, straightforward and useful!
The good
This module gives the CMS editors the full power to manage their redirects. Or even add query strings to the destination, e.g. letting a user go from /about/ to /about-us/?ga=about_visitor, giving a lot of options to have analytics better grouped and easier to read. This is very good for CMS experience and the ability to manage where people go when an old URL is entered.
The redirects are also followed by search engines so all pages are still properly indexed.
Some concerns
It’s not often I have some concerns with a module of the month, but there’s a first for everything. The redirect module requires the entire request to be handled by the framework before redirecting. A direct redirect from your web server (e.g. Apache or Caddy) is way faster in response time, because it doesn’t hit the framework.
Is this actually that big of an issue? Not really, the framework is fast enough that a visitor to the website would most probably not even notice a difference, but it’s still a minor downside.
You could compare it to a store having a sign saying “we’ve moved to a new address” on the door versus a store having that same sign at the counter. It takes a bit longer to realise that it’s moved. And so does your browser.
Does this concern outweigh the module’s core functionality? Not at all. The CMS editors expect a system that works. This small technical concern is overshadowed by the joy this module will bring to CMS editors of large websites.
Conclusion
Give your CMS editors some space in the SiteTree by letting them make redirects in a different way.
As per usual, give it a try, contribute and enjoy!
If you want to get involved in the discussion around the SilverStripe CMS, join the SilverStripe forum
Post your comment
Comments
Posted by Alice Gray, 27/04/2018 3:32am (6 years ago)
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments