Regex 使用IIS/重写模块将站点重定向到SSL
我正在尝试使用IIS/重写模块将站点的所有URL重定向到SSL 我有这个规则,它适用于所有URL,除了包含名为“blog”的虚拟目录/应用程序的URLRegex 使用IIS/重写模块将站点重定向到SSL,regex,web-config,iis-8,url-rewrite-module,Regex,Web Config,Iis 8,Url Rewrite Module,我正在尝试使用IIS/重写模块将站点的所有URL重定向到SSL 我有这个规则,它适用于所有URL,除了包含名为“blog”的虚拟目录/应用程序的URL <rule name="Force WWW and SSL" enabled="true" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny"> <
<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
因此,将www.example.com/blog/post/test重定向到https不起作用,但www.example.com/pages/demo起作用
出于某种原因,www.example.com/blog会重定向,但www.example.com/blog/不会
如果有人能给我指出正确的方向,请。我讨厌这种重写/regex的东西如果你想在所有URL上强制某个特定站点使用HTTP到HTTPS,那么我讨厌regex
- 只需在站点上创建URL重写规则
- 使用通配符类型,因为它们不太容易理解
<rewrite>
<rules>
<rule name="HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
通常,当我使用URLEwrite/redirection时,我使用重定向类型“temporary”,这样浏览器就不会缓存HTTP到HTTPS规则。完成测试后,我将重定向类型更改为永久。谢谢,但没有区别。我确信这与博客虚拟目录有关。任何带有/blog/的url都不匹配。博客是一个web应用程序,带有web.config,但其中没有任何规则。我在IIS中单击了“还原到父级”