Challenge:
Howdy friends, Sorry for being away for a while. But was busy with lot of things. I am back here to share my new Sitecore basics with you!
We have been revamping our site on newer Sitecore version. And we are near to launch. Site is already live and we have few sections/pages which are already indexed by Search engines and people might have already bookmarked it. But in new site those pages section has been changed or they have been moved. Sound similar? I guess most sites will have this challenge.
And as you would have done in this case. We also searched for good Sitecore 301 Redirect module. But I have been overwhelmed with lot of results, module and options. But to be honest, we were looking for simple solution which should do following things:
- Look for exact source URL and redirect it to either internal item or external URL
- Look for pattern and redirect to URL — Might want to preserve querystring
Simple?! You are also looking for same. Then this post is for you! Keep reading..
Solution:
After spending some time going through each module. This module took my attention : https://marketplace.sitecore.net/en/Modules/3/301_Redirect_module.aspx Because it looks simple, rating is high, and github is active!
We downloaded required package and installed it : https://github.com/thecadams/301RedirectModule
Now, you are all set!
- All redirects resides under: /sitecore/system/Modules/Redirect Module. So, If you have content authors role. Make sure they have access
- I faced some issue in my local with SC 8.1 Updated1 – Where for one of the item Response Status — Item’s version was not created. So, If you also face such issue. Please double-check each item and field have versions created
- There are two type of redirects :
- Redirect Url : Here you can provide Source URL and then where to redirect – You can redirect to Item or specific URL — We recommend Response Status Code as 301 – Moved Permanently. So, Search engines know that this page has been shifted to new URL. Mostly this will have one to one mapping. Example: When request comes from : http://localhost.SCBasics.com/demo.job-postings/job-detail?jid=16846 it should redirect to : http://localhost.SCBasics.com/job-search/job-detail?jid=16843
- Redirect Pattern: This can be used to group by URLs. When you have source URL request matching some pattern and you would like to redirect on particular item you can use this. As per below example any request coming from any URL having job-posting/job-detail (Pattern : ^/job-postings/job-detail(?<OptionalQueryString>\?.*)?$) in URL should be redirected to Job Detail page with QueyrString (/sitecore/content/SCBasics/Job Search/Job Detail${OptionalQueryString)
- For more examples please refer : https://github.com/thecadams/301RedirectModule#examples
- It also provides N number folder support. So, It is good practice to follow it!
- And If you have a lot of redirects and would like change how redirect item gets resolved (fast, query, api) or would like to change where this module looks for 301 Redirect items then have a look at : SharedSource.RedirectModule.config
That’s it!
Happy Redirection! 🙂