3

I'm using IIS 8.5 with the URL Redirect module installed.

My use case is that we have a defunct web site (www.xyz.com) and would like all requests to this site be redirected to another site (www.123.com). In the web.config of www.xyz.com I've added the following code:

<system.webServer>
  <rewrite>
    <globalRules>
      <rule name="Redirect to 123.com" stopProcessing="true" enabled="true">
        <match url="(.*)" ignoreCase="true" />
        <action type="Redirect" url="http://www.123.com/" redirectType="Permanent" />
      </rule>
    </globalRules>
  </rewrite>
</system.webServer>

I don't get any errors but I don't get a redirect either. It just goes to www.xyz.com as always. What am I missing to get this redirect to work?

Thanks

1
  • xyz.com and 123.com are on the same webserver ?
    – Swisstone
    Apr 15, 2020 at 19:02

1 Answer 1

0

The first thing to check is, does DNS for www.xyz.com point to the same IP address as www.123.com? Sorry for asking here in an "Answer", but I don't have enough points to add a comment yet.

Second, assuming number one is correct, your rewrite rule has no conditions specified so it would do this redirect for every request to your site, even if the URL already specified www.123.com. Try this instead:

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Redirect to 123.com" stopProcessing="true" enabled="true">
        <match url="(.*)" ignoreCase="true" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^www\.xyz\.com$" />
        </conditions>
        <action type="Redirect" url="http://www.123.com/" redirectType="Permanent" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>
7
  • Thanks but I don't think changing the DNS makes sense. I can't point the DNS (for xyz.com) at 123.com because it's a hosted site and I'm only allowed one domain. The idea is that whatever requests come to xyz.com, they're redirected to 123.com. I tried your updated RegEx in the condition node but it still resolves to xyz.com.
    – BKahuna
    Apr 15, 2020 at 22:20
  • @BKahuna so are you adding this rule to the webserver that hosts xyz.com?
    – CB_Ron
    Apr 18, 2020 at 18:15
  • Yes, I'm modifying the web.config on xyz.com. 123.com is hosted site with a shared IP.
    – BKahuna
    Apr 20, 2020 at 16:28
  • @BKahuna You need to install the latest Application Request Routing on xyz server. Do you have access to IIS manager on it? Navigate to the site, then click URL Rewrite, then Add Rule. Click Reverse Proxy - it will prompt you to install ARR and also update URL Rewrite if necessary. After it installs, just click cancel on creating the new rule. Your redirect should work now.
    – CB_Ron
    Apr 20, 2020 at 21:35
  • Thanks for the clever work around to get ARR installed. Unfortunately, after the install the redirect still doesn't work. While I wasn't prompted to restart anything, I did restart the xyz.com but it didn't fix it. This is a production server so I'm limited to what I can do during the day but will reboot the entire server tonight and see if anything shakes loose.
    – BKahuna
    Apr 22, 2020 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.