Sitecore URL Rewrite and Redirect using IIS rewrite module

There are many Sitecore URL redirect modules for 301 redirections and URL Rewrite modules in Sitecore Marketplace which you need to install separately. This article demonstrates  Sitecore URL Rewrite and Redirect using IIS rewrite module which is traditional .NET approach.

Sitecore URL Rewrite and Redirect using IIS rewrite module

Follow the detailed steps to perform URL Rewrite and 301 redirects in Sitecore without writing any code.

#1. Install URL Rewrite 2.0 Module from the Microsoft. There are different versions for x64 and x86. Download and install it according to the OS and IIS installed.

#2. Once the installation is done, Go to IIS Manager and verify for the URL Rewrite icon. If the installation is success then you will see the URL rewrite icon in the IIS.

#3. Create a config file RewriteRules.config in the App_Config folder of Sitecore. Add all the Rewrite rules in this file.

#4. For Redirections, you could create a file called as RewriteMaps.config in the App_Config folder of Sitecore. Add all the static redirections and rewrite maps in this config file.

#5. Open the web.config in the root folder and add the below lines to make it work. Just add these lines above the closing tag of </system.webServer>

      <rewriteMaps configSource="App_Config\rewritemaps.config" />
      <rules configSource="App_Config\RewriteRules.config" />

#6. Restart the IIS and the URL rewrite and redirects should work like a charm. You do not have to install any Modules, or write any code.

Sitecore URL Redirect and Rewrite Example:


<?xml version="1.0" encoding="utf-8"?>
<rule name="Redirect rules" patternSyntax="ECMAScript" stopProcessing="true">
    <match url=".*" ignoreCase="true"  />
    <conditions trackAllCaptures="true">
      <add input="{MyRedirects:{REQUEST_URI}}" pattern="(.+)" />
      <add input="{HTTP_HOST}" pattern="^(www.)?$" />
    <action type="Redirect" url="{C:0}" appendQueryString="false" redirectType="Permanent" />


<?xml version="1.0" encoding="utf-8" ?>
   <rewriteMap  name="MyRedirects"  >
    <add key="/home.html"  value="/home.aspx"/>
    <add key="/about-us.html"  value="/about-us"/>


      <rewriteMaps configSource="App_Config\rewritemaps.config" />
      <rules configSource="App_Config\RewriteRules.config" />
Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like