【发布时间】:2012-01-01 16:54:46
【问题描述】:
我真的被这个困住了......
基本上,我正在尝试使用 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>
更新:找到这篇文章:Rewrite http to https on some pages only using .htaccess。自 2010 年 3 月以来没有任何答复...!
【问题讨论】:
-
“自 2010 年 3 月以来没有任何答复......!” ==> 你为什么使用 IIS?我可以在不到一眨眼的时间里用 Apache 回答。更好、更快、更安全和免费(以每一种方式)。抱歉,我帮不上忙。
-
谢谢奥利弗。是的,结果比我想象的要容易。 :P 据我所知,这个 URLRewrite 插件可以做和 htaccess 一样的事情。但是,是的,我也更喜欢 htaccess(使用时间更长、资源更多等)。我相信您甚至可以将 htaccess 与 IIS 一起使用。
标签: iis redirect ssl rewrite url-rewriting