I have two domains, one is shortened and is used when sending text messages with a query string because the regular domain is too long. Currently, a web page on a different IP address redirects the short domain to the long one, either to a particular page if it has the correct query string, or to the home page if it does not. I'm moving to Azure where I will have only one IP address. So I figured IIS URL Rewrite would be able to handle this task. Long domain is a HTTPS only site, and there is a HTTPS rule for it. Short domain is not; the links are always HTTP only. I've setup URL Rewrite to do the Redirects before the HTTPS rule and stopProcessing="true" is set for both rules. But when I visit http://mytxt.net, I get a browser warning that the SSL cert is invalid.
The server is Windows Server 2016 IIS 10. I've searched Google and Stack Oveflow specifically but haven't found anything matching my issue. Below is the code.
<rule name="Txt QS Redirect" stopProcessing="true">
<match url="^(www\.)?mytxt\.net"/>
<conditions>
<add input="{QUERY_STRING}" pattern="^MyQS"/>
</conditions>
<action type="Redirect" url="https://www.myfullsite.net/respond.aspx" appendQueryString="true" redirectType="Temporary"/>
</rule>
<rule name="Txt No QS Redirect" stopProcessing="true">
<match url="^(www\.)?mytxt\.net"/>
<conditions trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="^MyQS" negate="true"/>
</conditions>
<action type="Redirect" url="https://www.myfullsite.net/" redirectType="Permanent"/>
</rule>
<rule name="HTTPS Redirect">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="^OFF$"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
</rule>
Shouldn't the redirect happen first, and then the protocol change to HTTPS? Or are the browsers checking for SSL first, and when IIS says it is enabled, doing the protocol change on the client?