Redirection in SXA
301 redirect. That's something we use a lot on websites when there is a change in some part of URL. If not, your old URL or bookmark throws 404. So, to achieve the redirection, we can use regex in config file and redirection happens and gives a valid page with 200 response. All good.
What if you are using a SXA site and want to do redirections but don't want to make changes to the config because it needs to go through your CI/CD pipeline and its time-taking process. So, SXA comes with an inbuilt redirection module. There are various types of redirections.
1-1 redirection
If you have an item in your content tree and the name of that item is changed. So, you want to make a redirection. You can do this by simply adding an item of template: /sitecore/templates/Feature/Experience Accelerator/Redirects/Redirect . All you have to do is to add an item of this template to your content tree where your old item is present and name it with the old item name. So your request reaches this item and then in the item you can give a reference to the new item where it should be redirected to. This will do the redirection without any further steps. That's it!
Redirection using Redirection Map
In this above image, the first example shows the 1-1 redirection using a redirect map. This is the simple way of doing the 1-1 redirection. You can add as many redirections as you want. Example 2, you can see the redirection using a regular expression. This will work for the page the redirectest and also any subpages that are under the redirectest. If you see on the right-hand side, there is $1, $2 which are acting as tokens and they will take care of that extra text that is before the keyword and after the keyword.
Comments
Post a Comment