List of useful SharePoint redirect rules for URL Rewrite

Want create site? Find Free WordPress Themes and plugins.

Note: This article is in draft yet and I’m still working on it.

Sometimes after moving SharePoint content (files, lists, sites, etc.) to a new place, you need to keep old links working. Sometimes you need to force users to use HTTPS instead of HTTP by redirecting them automatically. In these kinds of situation you can use the power of IIS URL Rewrite extension to achieve your goal.

If you have never worked with this extension, you can have a look at my post about it: Walkthrough: How to keep old SharePoint links working after a migration.

This post contains list of URL Rewrite rules which can be useful for SharePointers.


Useful IIS URL Rewrite rules for SharePoint

  1. Redirect users from HTTP to HTTPS
  2. Redirect users from one site collection to another
  3. Redirect users from one library to another
  4. Direct links to files opened in Word or Excel viewers to new file locations

Redirect users from HTTP to HTTPS
When a user opens any HTTP link on your site, the rule redirects him to the same link, but on HTTPS.
http://sp >> https://sp
http://sp/sites/mysite/docs >> https://sp/sites/mysite/docs

<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

Redirect users from one site collection to another
In this type of redirect all the library and file links from the old site collection lead to the same libraries and files on the new one.
http://sp/sites/oldsite >> http://sp/sites/newsite
http://sp/sites/oldsite/docs >> http://sp/sites/newsite/docs

<rule name="Redirect from one site collection to another (from oldsite to newsite)" enabled="true" stopProcessing="true">
    <match url="^(sites/oldsite)(.*)$" />
    <action type="Redirect" url="http://{HTTP_HOST}/sites/newsite{R:2}" redirectType="Found" />
</rule>

Redirect users from one library to another

From old library to the new one (if a user opens “Shared Documents” library, he will be redirected to “Style library”).
http://spdev/sites/my/Shared%20Documents >> http://spdev/sites/my/Style%20Library

From any file or folder in old library to the same file or folder in the new one.
http://spdev/sites/my/Shared%20Documents/Media%20Player >> http://spdev/sites/my/Style%20Library/Media%20Player

Note: in the inbound URL there is %20 (escaped space character), whereas we use just space in the rule.

<rule name="From one lib to another" enabled="true" stopProcessing="true">
    <match url="^(sites/my/Shared Documents)(.*)$" />
    <action type="Redirect" url="http://{HTTP_HOST}/sites/my/Style%20Library{R:2}" />
</rule>

Direct links to files opened in Word or Excel viewers to new file locations
Sometimes your users bookmark links not to file in the library, but to these files opened in Office viewers or Excel Services. In this case, we can get URL of the file from id parameter of the request.

<rule name="Word" enabled="true" stopProcessing="true">
    <match url="(_layouts/WordViewer.aspx)" />
    <action type="Redirect" url="http://sp/sites{C:2}" appendQueryString="false" redirectType="Temporary" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="(id=)(.*?)&amp;(.*)" />
    </conditions>
</rule>

<rule name="Excel" enabled="true" stopProcessing="true">
    <match url="(_layouts/xlviewer.aspx)" />
    <action type="Redirect" url="http://sp/sites{C:2}" appendQueryString="false" redirectType="Temporary" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="(id=)(.*?)&amp;(.*)" />
    </conditions>
</rule>
Did you find apk for android? You can find new Free Android Games and apps.

2 thoughts on “List of useful SharePoint redirect rules for URL Rewrite

  1. Pingback: Walkthrough: How to keep old SharePoint links workingSharePoint 2013 Developer's Blog

Leave a Reply

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