Iis 强制HTTPS上的某些页面和HTTP上的其他页面。。。可能吗?

Iis 强制HTTPS上的某些页面和HTTP上的其他页面。。。可能吗?,iis,redirect,ssl,rewrite,url-rewriting,Iis,Redirect,Ssl,Rewrite,Url Rewriting,我真的被这件事困住了 基本上,我正在尝试使用用于IIS的URLRewrite插件使2个页面始终通过SSL。但我还需要强制所有其他页面使用HTTP(叹气——不要问) 但是如果我通过HTTP强制其他页面,那么当您查看SSL页面时,您将收到安全警告。我试图通过检查HTTP_REFERER是否是SSL页面来解决这个问题,然后让它仅通过SSL发送给该页面。这不起作用,因为如果有人单击SSL页面上的链接,它将停留在SSL上 这可能吗 这是我目前为止所做的: <rewrite> <r

我真的被这件事困住了

基本上,我正在尝试使用用于IIS的URLRewrite插件使2个页面始终通过SSL。但我还需要强制所有其他页面使用HTTP(叹气——不要问)

但是如果我通过HTTP强制其他页面,那么当您查看SSL页面时,您将收到安全警告。我试图通过检查HTTP_REFERER是否是SSL页面来解决这个问题,然后让它仅通过SSL发送给该页面。这不起作用,因为如果有人单击SSL页面上的链接,它将停留在SSL上

这可能吗

这是我目前为止所做的:

<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="Force HTTPS Payments" stopProcessing="true">
            <match url="(.+)payments.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 negate="true" url="((.+)login.aspx|(.+)payments.aspx)" />
            <conditions>
                <add input="{HTTPS}" pattern="^ON$" />
                <add input="{HTTP_REFERER}" negate="true" pattern="(.+)login.aspx" />
                <add input="{HTTP_REFERER}" negate="true" pattern="(.+)payments.aspx" />
            </conditions>
            <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>


. 自2010年3月以来一直没有答案

所以我最后做的是:

  • 强制对需要它的页面使用HTTPS
  • 强制所有其他页面使用HTTP,但第1点中的页面以及这些页面上引用的“/styles”和“/images”文件夹除外
  • 由于页面使用相对路径,因此它们会分别通过HTTP/HTTPS自动使用样式/图像

    <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>
    
    
    
    “自2010年3月以来没有应答…!”==>您为什么要使用IIS?我可以在不到一眨眼的时间内用Apache回答。更好、更快、更安全、更免费(在各个方面)。对不起,我没办法。谢谢奥利弗。是的,结果比我想象的要容易P据我所知,这个URLEwrite插件可以做与htaccess相同的事情。但是,是的,我也更喜欢htaccess(使用时间更长,资源更多,等等)。我相信您甚至可以将htaccess与IIS一起使用。