URL Redirection solution for migration of SharePoint On-Prem sites to Office 365

Senthil Kumaresan
 
SharePoint Consultant
January 13, 2020
 
Rate this article
 
Views
5114

The Background

We had a medium sized SharePoint environment with 2000 sites which includes hierarchical sub sites created and maintained by the IT Department.
There were 8 major departments in the organization which had 8 large Sitecollections with a lot of Subsites created for sub departments within the company.

We planned to migrate all the 2000 sites to SharePoint online. We were planning to migrate all the 8 hierarchical Site collections with 2000 subsites to a Flat structure.

Microsoft has been recommending organizations to redesign the Site structure to a flat structure instead of a Hierarchical structure. We wanted to utilize the Modern Hub and Standalone satellite sites model instead of a large 8 hierarchical site collections with subsites. We planned to migrate each subsite into its own site collection. There are some exceptions that some site collections may have 1 level subsite as they were so tightly built and using features that are inherited from its parent site. So we ended up creating 1500+ site collections which were connected to 8 departmental Hub sites. There were further reorganization into additional hubs based on business needs.

In order to achieve this, we built new departmental Hubs which will act as the home page for each departments within the organization.
To provide a seamless migration experience for end users, we had to redirect each subsite in SharePoint On-Prem to its own site collection in SharePoint online.

URL Redirection With IIS

We identified 4 levels of subsite hierarchy and planned to create IIS URL Redirection rules in the IIS URL Rewrite Module for the SharePoint web sites.

Since there are 1500+ subsites to be redirected, It’s not advisable to create 1500+ rules in a IIS web site. But IIS provides an option to create Rewrite Maps to which you can add a big list of sites to be redirected with a common rule.
You need to create Rewrite Maps and Rules for each level of the hierarchy.

Below is the sample 4 Redirection rules that was created in the IIS Website.

<rewrite>
      <rewriteMaps configSource="RewriteMaps.config" />
      <rules>
        <clear />
         <rule name="Rewrite for SharePointLevel4" enabled="true" stopProcessing="true">
          <match url="([^/]+/[^/]+/[^/]+/[^/]+)(/?.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{SharePointLevel4:{R:1}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}{R:2}" redirectType="Permanent" />
        </rule>
        <rule name="Rewrite for SharePointLevel3" enabled="true" stopProcessing="true">
          <match url="([^/]+/[^/]+/[^/]+)(/?.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{SharePointLevel3:{R:1}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}{R:2}" appendQueryString="true" redirectType="Permanent" />
        </rule>
        <rule name="Rewrite for SharePointLevel2" enabled="true" stopProcessing="true">
          <match url="([^/]+/[^/]+)(/?.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{SharePointLevel2:{R:1}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}{R:2}" appendQueryString="true" redirectType="Permanent" />
        </rule>
        <rule name="Rewrite for SharePointLevel1" enabled="true" stopProcessing="true">
          <match url="([^/]+)(/?.*)" />
          <conditions logicalGrouping="MatchAny" trackAllCaptures="true">
            <add input="{SharePointLevel1:{R:1}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}{R:2}" appendQueryString="true" redirectType="Permanent" />
        </rule>
        <rule name="HTTPRedirect" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
        </rule>
      </rules>
    </rewrite>

RewriteMap.config — Below is the sample of rewrite maps that we created for all the 4 levels of subsite hierarchies. You can add as much sites as you want under each levels of hierarchy.

<rewriteMaps>
	<rewriteMap name="SharePointLevel1" >
		<add Key="IT" value="https://contoso.sharepoint.com/sites/IT" />
		<add Key="Finance" value="https:// contoso.sharepoint.com/sites/Finance " />
    </rewriteMap>
    <rewriteMap name="SharePointLevel2" >
		<add Key=" Finance /Connect" value="https:// contoso.sharepoint.com/sites/Fi-Connect" />
		<add Key=" Finance /Tax" value="https:// contoso.sharepoint.com/sites/Fi-Tax" />
    </rewriteMap>
    <rewriteMap name="SharePointLevel3" >
		<add key=" Finance / Tax /Audit" value="https:// contoso.sharepoint.com/sites/FI-Tax-Audit" />
		<add key=" Finance / Tax /GST" value="https:// contoso.sharepoint.com/sites/FI-Tax-GST " />
    </rewriteMap>
     <rewriteMap name="SharePointLevel4" >
		<add key=" Finance /Tax/ Audit /SharedServices" value="https:// contoso.sharepoint.com/sites/FI-Tax-Audit-SharedServices" />
		<add key=" Finance / Tax/Audit /GRA2018 " value="https:// contoso.sharepoint.com/sites/FI-Tax-Audit-GRA2018 " />
    </rewriteMap>
</rewriteMaps>

Once the rules and rewrite maps are created, you will be able to add subsite URLs as per the above example whenever you migrate them to SharePoint online. Users would seamlessly be redirected to the migrated SharePoint online website.

Note : In this approach, you cannot redirect a parent level web site unless you migrate all the subsites of the parent site. If you try to add the parent site to the rewrite maps, then users cannot access your child site which is not migrated. They will be redirected to the parent site. Add a Parent site to Rewritemap only when you have migrated all child sites and added them to the relevant child level rewritemap.
Category : Office 365, OnPremise

Author Info

Senthil Kumaresan
 
SharePoint Consultant
 
Rate this article
 
SharePoint Architect – Consulting on SharePoint Infrastructure, IT Governance and Apps Development. ...read more
 

Leave a comment