Can I re-route POST request traffic in my web config when the url has changed using rewrite?

Viewed 39

I am in the process of updating my API calls from www CNAME to api CNAME. The website and API calls are hosted on an ASP.Net application hosted on Azure web apps.

I am wanting to put a new website onto the www CNAME which is hosted in S3. So any old api calls, such as https://www.myexampleorg.com/api/mypostrequest will no longer be valid.

The issue I have is that I have a mobile application which uses these www calls, I pushed out an update a month ago to change these, but for anyone that doesn't have auto updates on this may not be on their device. I can also see hundreds of people a day still updating so it's obvious that not everyone has updated that can.

I was hoping to do something like this in my web config... would this work and respond with the correct values as if it were coming from the correct cname?

So https://www.myexampleorg.com/api/mypostrequest would return as if it had hit https://api.myexampleorg.com/api/mypostrequest?

Or is there any other way around this?

<rewrite>
  <rules>
    <rule name="Redirect old API calls" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www.myexampleorg.com/api$" />
      </conditions>
      <action type="Redirect" url="https://api.myexampleorg.com/api{R:0}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>
0 Answers
Related