Skip to content
January 13, 2021 / kiranpatils

SXA Lower case URL

Challenge:

As per SEO Best practice, We were trying to set all URLs to lower case for our SXA Solution.

Based on my NON-SXA Learning. I thought it will be changed in one place. But it had changed at one more place. Which I couldn’t locate easily from the documentation. So, thought to share with you to save your time!

Solution:

We made following change:

But that didn’t give us the desired results. A quick search helped us to find this post which outlines a few approaches: https://sitecore.stackexchange.com/questions/16504/sxa-search-results-render-link-url-lowercase (Thank you!)

We tried following config file and it worked!

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<linkManager>
<providers>
<add name="localizedProvider">
<patch:attribute name="lowercaseUrls">true</patch:attribute>
</add>
</providers>
</linkManager>
<links>
<urlBuilder>
<lowercaseUrls>true</lowercaseUrls>
</urlBuilder>
</links>
</sitecore>
</configuration>
view raw LowerCase.Config hosted with ❤ by GitHub
<rules>
<!– Take redirectType="Temporary" out of production if needed – Current live site has same configuration –>
<rule name="LowerCaseRule – not including querystring" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{PATH_INFO}" pattern=".*[A-Z]" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(sitecore)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(sitecore modules)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/-/" negate="true" />
<add input="{REQUEST_URI}" pattern=".*(-/media).*" negate="true" />
<add input="{REQUEST_URI}" pattern=".*(~/media).*" negate="true" />
<add input="{REQUEST_URI}" pattern=".*(~/icon).*" negate="true" />
<add input="{REQUEST_URI}" pattern="WebResource.axd" negate="true" />
<add input="{REQUEST_URI}" pattern="ScriptResource.axd" negate="true" />
<add input="{REQUEST_URI}" pattern="jsnlog.logger" negate="true" />
<add input="{REQUEST_URI}" pattern="Telerik.Web.UI.WebResource.axd" negate="true" />
<add input="{REQUEST_METHOD}" matchType="Pattern" pattern="POST" ignoreCase="true" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(identity)" negate="true" />
</conditions>
<action type="Redirect" url="/{ToLower:{R:1}}" appendQueryString="true" redirectType="Temporary" />
</rule>
</rules>

One more thing — If you are also looking for a way to redirect any URL to lower case then this is a great post: https://blog.coates.dk/2018/01/15/lower-casing-rewrite-rules-breaks-the-sitecore-client/ – I had to modify it for Identity service – Added our version (Tested on Sitecore 9.3) in the gist above.

Happy SEO!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: