As suggested by SEO, I'm trying to redirect similar URLs to one single URL. For example,
1) http://www.example.com/en/contact-us
2) http://www.example.com/en/contact%20us
3) http://www.example.com/en/contact-us/
Above three URLs take us to the same item in Sitecore. So I would like to make the URL in bold to be the main URL and other two URLs should have a 301 redirection to it.
I tried adding rewrite rule in IIS and could get the first URL to redirect. However, the second URL is not redirecting to the 3rd URL. See below config.
Web.config
<rewrite>
<rules>
<rule name="Redirect rule">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*example\.com.*" />
<add input="{ExamplePermanent:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false"
redirectType="Permanent" />
</rule>
</rules>
<rewriteMaps configSource="rewritemaps.config" />
</rewrite>
rewritemaps.config
<rewriteMaps>
<rewriteMap name="ExamplePermanent">
<add key="/en/contact-us" value="/en/contact-us/" />
<add key="/en/contact%20us" value="/en/contact-us/" />
</rewriteMap>
<rewriteMaps>
Is there any configuration that needs to be done in order to make the 2nd URL redirect with 301?
IIS will decode %20 to a space, so just replace that with space in rewritemaps:
<add key="/en/contact us" value="/en/contact-us/" />