0
votes

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.

1
enabled =""true" ? extra ".Looks like your web.config is not wellformedVK_217
That was typo, I edited it. any clue how to fix it ?IndieTech Solutions
when you say "domain" (ala domain2.com) is it truly a domain or just a virtual folder?Grady G Cooper
I fixed the xml example typovaldeci

1 Answers

0
votes

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.