Configure a rewrite url in web.config, for IIS hosted apps

Rewrite is not a redirect, it doesn’t respond with 3xx in an API call case, and doesn’t change the url in the browser in a web app case. It’s a mapping of urls from what is exposed by IIS to what is actually exposed by the app.

Here the documentation.

Simplest case

If the API exponses an endpoint “/internalendpoint” and I want to actually have it publicly as “/publicendpoint”

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="basic" stopProcessing="true">
                    <match url="^publicendpoint$" />
                    <action type="Rewrite" url="/internalendpoint" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>