Force some pages over HTTPS and others to HTTP… is it possible?

前端 未结 1 633
生来不讨喜
生来不讨喜 2021-02-04 21:29

I\'m really stuck on this one...

Basically, I\'m trying to make 2 pages always over SSL using the URLRewrite add-on for IIS. But I also need to force all other pages to

相关标签:
1条回答
  • 2021-02-04 22:03

    So what I ended up doing is:

    1. Force HTTPS for the page(s) that required it.
    2. Force all other pages to HTTP EXCEPT for the page(s) in point#1 and the "/styles" and "/images" folders that are referenced on these pages.

    Since the pages use relative paths, they automatically use the styles/images over HTTP/HTTPS respectively.

    <rewrite>
        <rules>
            <rule name="Force HTTPS Login" stopProcessing="true">
                <match url="(.*)/login.aspx" />
                <conditions>
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
            </rule>
            <rule name="Others Force HTTP" stopProcessing="true">
                <match url="(((.*)/login.aspx)|((.*)/styles(.*))|((.*)/images(.*)))" negate="true" />
                <conditions>  
                    <add input="{HTTPS}" pattern="^ON$" />
                </conditions>
                <action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>
    
    0 讨论(0)
提交回复
热议问题