HTTPS URL Rewrite Rule for Specific Page Using IIS 7.5

15,433

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 :)

Share:
15,433
Peter
Author by

Peter

NYC-based software developer and writer. Always interested in talking shop - feel free to reach out!

Updated on June 12, 2022

Comments

  • Peter
    Peter almost 2 years

    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.