Quantcast
Channel: Fun with SharePoint » Jasjit Chopra
Viewing all articles
Browse latest Browse all 5

Redirect old SharePoint sites to new SharePoint sites with deep URLs using IIS rewrite module and rewrite map

$
0
0

This is a fairly common scenario when we move from one SharePoint farm to another SharePoint farm with a new URL or consolidate multiple Legacy farms into one single SP farm and some restructuring also happens as it relates to what content goes to which web apps / site collections.

Before we begin make sure you have downloaded and installed the URL Rewrite extension from Microsoft for IIS. It can be found here. One thing to remember here is if you are using multiple SSL sites and want to have the redirect service on single IIS web server then you would need multiple internal IPs to bind those SSL certs to.

I will show you here in this example how we can handle a scenario where 2 SharePoint farms were migrated to single farm and redirects were configured.

So in this scenario we will go form http://teamsites.contoso.com in one farm and http://sharepoint.contoso.com in another farm to http://teamsites.fabrikam.com. Assuming we migrated http://teamsites.contoso.com sites from a SP 2007 environment to SP 2013 site http://teamsites.fabrikam.com and http://sharepoint.contoso.com from SP 2010 to SP 2013 site.

A visual table record is always handy to relate with the final outcome for your code. This mapping table shows our desired scenario for redirecting each URL.

URL Mapping Table

Old URL New URL
http://teamsites.contoso.com http://teamsites.fabrikam.com
http://teamsites.contoso.com/sites/HR http://teamsites.fabrikam.com/sites/HR
http://teamsites.contoso.com/sites/Sales http://teamsites.fabrikam.com/sites/Sales
http://sharepoint.contoso.com http://teamsites.fabrikam.com/sites/sharepoint
http://sharepoint.contoso.com/sites/Team1 http://teamsites.fabrikam.com/sites/Team1

Now assuming you have a dedicated IIS Web Server instance where you will run this redirect service from we will proceed to our next steps.

Create two websites in IIS and for this Demo I will call them “TeamRedirect” and “SharePointRedirect”. You will be asked to place them in a directory. Make sure that directory is empty and not being used by any other service or for any other purpose. By default the directory is going to be empty. We are now going to place the following two files in both sites empty directory: web.config and maps.config

Code for Web.config for “TeamRedirect” website: (Make sure to edit the bindings for this site to listen to teamsites.contoso.com on port 80)

xml version="1.0" encoding="UTF-8"?>

Note: The URL parameter in Action Type tag is responsible for the base URL for all target URLs, hence the missing “/” in the below mapping table for value pair. {C:1} is where the value pair from the map gets written to.

Code for maps.config for “TeamRedirect” website:

<rewriteMaps>

Note: The default value will send the user to root site including any other URL that does not match.

Code for Web.config for “SharePointRedirect” website: (Make sure to edit the bindings for this site to listen to sharepoint.contoso.com on port 80)

xml version="1.0" encoding="UTF-8"?>

Code for maps.config for “SharePointRedirect” website:

<rewriteMaps>
    <rewriteMap name="TeamsRedirect" defaultValue="/sites/SharePoint">
		<add key="/sites/Team1" value="sites/Team1" />
    </rewriteMap>
</rewriteMaps>

Note: Check the mapping table and note the default URL difference.

And that is it ! You are all set. Make sure your DNS entries point to this redirect service for the OLD SP sites.

I would also like to add another frustration I had to go through while testing this. All browsers cache permanent redirects differently and cannot be removed by clearing your normal cache from the browser. Just google the steps for each browser type and version you are using in case you want to revert back to old DNS entry (very helpful if testing via local host entry).

I have personally tested the rewrite map with 1200 or so entries and it has worked like a charm. If anyone tests this with more entries do let me know I would love to hear if that works well enough too. Microsoft does not document any hard limit for the number of entries this map can actually have.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images