Neem contact op

SXA Redirect URL with Country Code

Technical Leader
Valtech, India

juni 30, 2018

It is important to redirect users to the new page from the old page when we have created a new version of an existing web page. It helps both users and search engines to get redirected to a new URL from the one they originally requested.

sxa-redirects.png

There are several ways to setup redirects in Sitecore solution, with Sitecore SXA we have redirect tool in place that facilitates setting up old and new URLs in Sitecore. We can use the mapping tool to set up a 301/302 or server transfer redirect.

Recently we worked on setting up redirects using SXA redirect tool, for most of the redirects we had country code in the old URL.

Here are some example URLs:

Old URLen-au/sample-old-page-name  

New URL– /new-page-name

 

Old URLen-au/mypage/pagelisting  

New URL– /newpagelisting

What we observed that after setting up old URLs which has country code on it- all such URLs were redirecting to 404 page.

We can fix this by appending “sc_lang” querystring parameter to the new URL with the target country code, see below examples for ref:

Old URL– /sample-old-page-name  

New URL– /new-page-name/?sc_lang=en-AU

 

Old URL– /mypage/pagelisting  

New URL– /newpagelisting/?sc_lang=en-AU

After this redirects works as expected.

 

I hope this helps.

Happy Learning!

Neem contact op

Let's reinvent the future