我真的被这个困住了...
基本上,我尝试使用 IIS 的 URLRewrite 附加组件始终通过 SSL 制作 2 个页面。但我还需要强制所有其他页面使用 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>
更新:找到这篇文章:仅使用 .htaccess 在某些页面上将 http 重写为 https https://stackoverflow.com/questions/2357455/rewrite-http-to-https-on-some-pages-only-using-htaccess/8191154#8191154。自 2010 年 3 月以来一直没有答复...!
所以我最终做的是:
- 对需要它的页面强制使用 HTTPS。
- 强制所有其他页面使用 HTTP,除了 point#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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)