针对特定模式的IIS 7.5 URL重定向
当用户进入domain.com时,它应该重定向到我的应用程序。目前没有发生这种情况,它显示了一个页面“此连接不受信任” 我的web.config中添加了以下重写标记:针对特定模式的IIS 7.5 URL重定向,iis,url-rewriting,iis-7.5,Iis,Url Rewriting,Iis 7.5,当用户进入domain.com时,它应该重定向到我的应用程序。目前没有发生这种情况,它显示了一个页面“此连接不受信任” 我的web.config中添加了以下重写标记: <rewrite> <rules> <rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" />
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
目前在我的IIS 7.5中,我添加了入站规则,设置如下:
提前感谢。您的重写规则只是重定向到同一个域。因此,如果用户只输入
domain.com
(默认为http),它将重定向到https://domain.com
。如果您的SSL证书不包含domain.com
,而只包含www.domain.com
,则会导致浏览器提示错误证书的警告。尽管现在大多数证书颁发机构都会颁发包含和不包含www的域的证书(但可能不是您的域)
如果希望用户始终使用https://www.domain.com
(始终使用www)您应该使用以下重写规则:
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" negate="true" pattern="^ON$" />
<add input="{HTTP_HOST}" negate="true" pattern="^www\.domain\.com$" />
</conditions>
<action type="Redirect" url="https://www.domain.com{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
</rule>
它将强制SSL并强制
www.domain.com
作为主机头。如果没有,它将向同一URL发出永久重定向(=beter)。您的重写规则只是重定向到同一域。因此,如果用户只输入domain.com
(默认为http),它将重定向到https://domain.com
。如果您的SSL证书不包含domain.com
,而只包含www.domain.com
,则会导致浏览器提示错误证书的警告。尽管现在大多数证书颁发机构都会颁发包含和不包含www的域的证书(但可能不是您的域)
如果希望用户始终使用https://www.domain.com
(始终使用www)您应该使用以下重写规则:
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" negate="true" pattern="^ON$" />
<add input="{HTTP_HOST}" negate="true" pattern="^www\.domain\.com$" />
</conditions>
<action type="Redirect" url="https://www.domain.com{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
</rule>
它将强制SSL并强制
www.domain.com
作为主机头。如果没有,它将向同一URL发出永久重定向(=beter)。如果我以www.domain.com的形式输入URL,它会正常工作,因为它会正确重定向到。但如果我以domain.com的形式输入URL,则会显示错误页面“连接不可信”。这是因为iam使用https。如果我以www.domain.com的形式输入URL,它可以正常工作,因为它可以正确重定向到。但如果我以domain.com的形式输入URL,则会显示错误页面“连接不可信”。这是因为我使用https。