IIS URL Rewrite rule using request header

2.4k views Asked by At

I have been trying to creat an IIS Rewrite rule that looks at the incoming Header for an API and if it contains a certain string re-direct them to a certain page and not the API (Noobs - Using documentation API Keys)

Been at it 2 hours and just can't work it out. Could anyone help?

Thanks

1

There are 1 answers

0
user1702595 On

Finally Got it! Here is teh rule below for anyone else that is interested.

     <rewrite>
        <rules>
            <rule name="Rewrite Noob Documentation API Key" enabled="true" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTP_Authorization}" pattern="^ukvd-ipwhitelist ABCD1234-1b3d-4d63-aa75-ABCDEF123456$" />
                </conditions>
                <action type="Redirect" url="https://xxx.co.uk/dockey.html" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>