Redirecting old domain to new domain on windows hosting

44 Views Asked by At

I have an old website hosted on A2 Hosting and I'm trying to redirect it to my new domain hosted on GoDaddy. I've tried editing the "HTTP to HTTPS Redirect" rule on my web.config, however, it is still not redirecting.

<rewrite>
        <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
            <match url="(.*)" /> 
            <conditions> 
                    <add input="{HTTPS}" pattern="^www.test.gov.mp$" ignoreCase="true" />
            </conditions> 
            <action type="Redirect" redirectType="Permanent" url="https://www.test.health/{R:1}" />
            </rule>   
        </rules>
        </rewrite>

test.gov.mp is my old domain and test.health is my new domain.

1

There are 1 best solutions below

0
samwu On

If you want to redirect www.test.gov.mp to www.test.health, you can refer to this rule. The pattern is using a regular expression, to check if {HTTP_HOST} is equal to www.test.gov.mp, the {R:1} in the action means whatever is in the URL behind the domain name itself.

<rule name="test" stopProcessing="true">
   <match url="(.*)" />
      <conditions>
         <add input="{HTTP_HOST}" pattern="^www.test.gov.mp$" />                 
      </conditions>
   <action type="Redirect" url="http://www.test.health/{R:1}" />
</rule>