HTTPS URL Rewrite Rule for Specific Page Using IIS 7.5

httpsiis-7.5url-rewriting

I am trying to get URL rewrite in IIS 7.5 to redirect to HTTPS for a "single page".
The rest of the domain should remain HTTP.

To do this, I am editing my Web.config file. Can somebody tell me what I am doing
wrong in the below rule:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="SpecificRedirect" stopProcessing="true">
                <match url="^register.aspx$" />
                <action type="Redirect" url="https://mail.domain.org/register.aspx" />
            </rule>
        </rules>
    </rewrite>
  </system.webServer>

Below is what my URL Rewrite module looks like in IIS 7.5

enter image description here

thanks much.

Best Answer

I think you are very close, but your redirect will cause infinite loop. Try this:

<rule name="SpecificRedirect" stopProcessing="true">
    <match url="^register.aspx$" />
    <conditions>
        <add input="{HTTPS}" pattern="^off$" />
    </conditions>
    <action type="Redirect" url="https://mail.domain.org/register.aspx" />
</rule>

Let me know if you have to handle multiple domains, then the rule will need more complex rewrite url.

EDIT: obviously we need Redirect not Rewrite :)