我在Web.config的<system.webServer>下有一个条目
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.mydomain.com*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>我希望对http://www.mydomain.com的请求将被重定向到https://www.mydomain.com。然而,这种情况并没有发生。
规则的格式有问题吗?还必须做一些其他的事情来启用重定向吗?
这是在IIS8下的Windows2012计算机上运行的。RewriteModule列在该网站的模块下面。
发布于 2014-03-13 20:36:43
删除"(.mydomain.com*)"并将其设置为"(.*)"
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>发布于 2014-03-13 20:33:05
确保安装了IIS重写模块(使用Web平台安装程序可安装)。然后,您可以使用IIS来查看、配置和测试重写规则。
编辑:我注意到你说你已经确认模块已经安装了。凉爽的!很可能这是规则本身的问题。使用IIS提供的测试工具验证它的工作方式。
编辑2:我认为您的规则的问题在于您的匹配URL语法。根据语法,默认语法是ECMAScript正则表达式。这意味着,如果要匹配.字符,就必须使用\.。
https://stackoverflow.com/questions/22390195
复制相似问题