Feb 17
Redirect URL’s (Root And Subsites) For SharePoint And IIS Sites


On occasion you may find the need to export a web site within a site collection to a new location or namespace (Site Collection). Once you do this you will likely be left with the old site which others will continue to visit because they are bookmarked or you may have decided to delete the old site. Obviously you could create a redirect at the root of the site or even each subsequent site, however this is a daunting and prone to error. However what happens if an End-User visits a site that is deeply nested within the site that has been moved, they will surely get an ASP.Net page error or a missing Site or Google might have directed them to a site that no longer exists, providing the not so accurate location of the moved site.

In order to fully address the above situation you can create a redirect that a colleague of mine created which can be modified on each of the Web Front End within your SharePoint or any IIS environment.

The following is a real world example for our Indiana University SharePoint Users' Group site:
https://sp.indiana.edu/iuspug needs to be redirected to https://iuspug.iu.edu/


You will need to first install a Microsoft IIS tool named URL Rewrite which is an extension tool for IIS that is built on an open and modular architecture that allows you customize and add new features through free IIS Extensions. They are regularly adding new features to IIS to help you optimize your website for search, serve media to multiple platforms and devices, deploy web applications, route URL requests and more!

http://www.iis.net/download/urlrewrite Install it on each Web Front End Server.

  • On each Web Front End server you will need to navigate to and edit the web.config for the web application (Application Pool).
  • Navigate to the Virtual Directory that has the web application
    • C:\inetpub\wwwroot\wss\VirtualDirectories
      • Create a backup of the web.config file (i.e. copy-web.config)
      • Open the web.config in Notepad
        • Search for <system.webServer> (make certain to not confuse </system.webServer> with <system.webServer>.
          • Add the following text to the line after <system.webServer> and before <security>

       <!-- URL Rewrite rules -->
                <!-- Redirect /iuspug/* to iuspug.iu.edu/* -->
                <rule name="Rewrite Forum" stopProcessing="true">
                    <match url="^iuspug/?(.*)" />
                        <add input="{HTTP_HOST}" pattern="^sp.indiana.edu$" />
                    <action type="Redirect" url="https://iuspug.iu.edu/{R:1}" />



Re: Redirect URL’s (Root And Subsites) For SharePoint And IIS Sites

 on 2/13/2015 2:59 PM

 ‭(Hidden)‬ Blog Tools