0

I need to redirect couple old webpages from my IIS to a new domain in a specific order. For instance :

domain1/page1 to domain2/page1

domain1/page2 to domain2/page3

domain1/page3 to domain2/page5

...

Here's my webconfig <system.webserver> section:

<system.webServer> 
     <rewrite> 
        <rules> 
             <rule name="redirect single page" patternSyntax="ExactMatch" stopprocessing="true"> 
                 <match url="domain1/page1"/> 
                 <action type="redirect" url="domain2/page1" appendquerystring="false"/> 
             </rule> 
         </rules>    
     </rewrite> 
     <httpredirect enabled ="true" destination"Domain2" httpresponsestatus="permanent"/> 
</system.webServer>

But the redirecting is not happening it still points to the old domain pages.

Community
  • 1
  • 1
IndieTech Solutions
  • 2,527
  • 1
  • 21
  • 36

1 Answers1

0

Accordingly the @Claus answer on the question: 301 Redirect one domain to another using web.config

You can use the following code to achieve this:

  <system.webServer> 
    <rewrite>
      <rules>
        <rule name="redirect" enabled="true">
          <match url="(.*)" />
            <conditions>
              <add input="{HTTP_HOST}" negate="true" pattern="^www.domain1.com$" />
            </conditions>
          <action type="Redirect" url="http://www.domain2.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  <system.webServer> 

This example will match all URLs unless the hostname part is exactly www.domain1.com - and redirect those to www.domain2.com/whatever.

valdeci
  • 13,962
  • 6
  • 55
  • 80