0

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.

spades0001
  • 55
  • 7
  • If `test.gov.mp` is your old domain, then why do you use `www.test.gov.mp` in your condition? They are not the same thing. – Lex Li Feb 22 '22 at 16:04

1 Answers1

0

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>
samwu
  • 3,857
  • 3
  • 11
  • 25