Redirect to new domain after rebranding with IIS Url Rewrite Module

Client has a bunch of domains and and websites. Because They have decided to change company’s name recently I was asked to proceed with chanage of domain names as well. After few weeks of constantly informing visitors about planned changed We decided that it is a good time to abandon old domains and redirect visitors to new ones. In order to “be okay” with google (their page ranks, indexed pages and so on) we make those redirects permanent (301 Moved Permanently as a response status code).

As all of the websites are hosted on IIS 7 I have decided to use URL Rewrite Module for the job. First of all – make sure You have Url rewrite module installed on Your server machine. Secondly, You need to update web.config file to something like the one that (assuming old-name):

  <system.webServer>
        ......
        <rewrite>
            <rules>
                <clear />
                <rule name="rebranding" enabled="false" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                        <add input="{HTTP_HOST}" pattern="(.*)old-name(.*)" />
                    </conditions>
                    <action type="Redirect" url="http://{C:1}new-name{C:2}/{ToLower:{R:1}}" appendQueryString="true" />
                </rule>                
            </rules>
        </rewrite>
  </system.webServer>

You can do that in IIS manager as well.
Some explanation here:

  • match url=”(.*)” – matches all request
  • trackAllCaptures=”true” – will enable to use captured grups in our redirect url
  • (.*)old-name(.*) – matches each HTTP_HOST that has ‘old-name’ within, like: ar.old-name.com or www.old-name.ru
  • http://{C:1}new-name{C:2}/{ToLower:{R:1}} – redirected url, R:1 stands for matches from and C:1 and C:2 matches those from conditions, ToLower changes text to lower case letters
  • appendQueryString=”true” – will append query string to newly generated url

Have fun

Share

Related posts:

  1. Handler “Elmah” has a bad module “ManagedPipelineHandler” in its module list
  • http://www.lockerpulse.com/Product-Blog/2011/11/13/miami-marlins-added-yahoo-duplicate-post-issues-resolved/ homepage backlinks

    I’m not sure where you are getting your information, but great topic. I needs to spend some time learning much more or understanding more. Thanks for wonderful information I was looking for this info for my mission.

  • http://itmeze.com Mike

    just a test

  • Clive

    A different approach I found at http://www.bigboot.com/iisredirects. It allows you to setup the script and a non technical person add and remove redirects at will. It also captures all the back links that might have been missed.

  • http://www.stayinbritain.co.uk/ Self Catering Cottages

    Very useful and timely info!

  • http://usjoomlaforce.com/ US Joomla Force

    thanks, at last i got it.