Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS URL Rewrite Rule for Specific Page Using IIS 7.5

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.

like image 228
Peter Avatar asked Oct 21 '22 22:10

Peter


1 Answers

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

like image 85
Tomek Avatar answered Oct 29 '22 05:10

Tomek