Redirect On-Premise SharePoint Url’s to SharePoint Online Site with IIS URL Rewrite Module

The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find. You can use the URL Rewrite module to perform URL manipulation tasks, some of which include:

  • Define powerful rules to transform complex URLs into simple and consistent Web addresses.
  • Easily replace Web application URLs to produce user and search engine friendly results.
  • Rewrite URLs based on HTTP headers and IIS server variables.
  • Perform redirects, send custom responses, or stop HTTP requests based on the logic expressed in the rewrite rules.
  • Control access to Web site content based on URL segments or request metadata.

You can read more about URL rewriting from the source web site

When you do a partial upgrade to SharePoint Online, you may want some list and page addresses to be forwarded to SharePoint Online and some list and page addresses to your on-premise SharePoint server.

For this, you must first determine which addresses you will forward and where you will forward them. For example;

On-premise URL: http://oldurl.domain.com/Pages/Default.aspx

SPO URL: http://domain.sharepoint.com/sites/upgradedSite/Pages/Default.aspx

Then you can activate the IIS URL Rewrite module on your on-premise server and proceed to the configuration phase.

With a configuration like the one below, you can forward the addresses with your old domain to the addresses you have specified under the new domain. Since routing will do one-to-one text validation, you should define static routing for all possible address combinations.

If you are using the Minimal Download Strategy feature on the on-premise SharePoint side, I suggest you deactivate it. Because this feature brings add-ons like start.aspx to list and page addresses, which causes redirects to break or add redirects for both possibilities.

<rewrite>
    <rules>
         <rule name="Redirect rule1 for StaticRedirects" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^oldurl.domain.com$" />
                <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="https://domain.sharepoint.com{C:1}" redirectType="Permanent" appendQueryString="false" />
        </rule>
    </rules>
    <rewriteMaps>
        <rewriteMap name="StaticRedirects">
            <add key="/Pages/home.aspx" value="/Pages/Default.aspx" />
            <add key="/Pages/abc.aspx" value="/Pages/Default.aspx" />
            <add key="/Lists/SamleList/AllItems.aspx" value="/Lists/SampleList/AllItems.aspx" />
        </rewriteMap>
    </rewriteMaps>
</rewrite>

Add a Comment

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