Url rewriting 在IIS[UrlRewite]中添加入站规则
目前,在我的生产服务器上,我有如下的入站规则集,它可以满足我的所有需求 入站规则如下所示Url rewriting 在IIS[UrlRewite]中添加入站规则,url-rewriting,iis-7.5,inbound,Url Rewriting,Iis 7.5,Inbound,目前,在我的生产服务器上,我有如下的入站规则集,它可以满足我的所有需求 入站规则如下所示 Match URL section Requested URL: Matches the Pattern Using: Regular Expression Pattern: (.*) Ignore Case: checked. Conditions section Logical grouping: Match All. Input: {HTTPS} Type: Matches the Pattern
Match URL section
Requested URL: Matches the Pattern
Using: Regular Expression
Pattern: (.*)
Ignore Case: checked.
Conditions section
Logical grouping: Match All.
Input: {HTTPS}
Type: Matches the Pattern
Pattern: ^OFF$
Track capture groups across conditions: unchecked.
Action section:
Action type: Redirect
Redirect URL: https://www.domainname.com/{R:0}
Append query string: checked.
Redirect Type: Permanent (301).
我的要求是:
当用户输入
https://beta.domain.com it should redirect to https://www.domain.com.
http://beta.domain.com it should redirect to https://www.domain.com.
如果用户类型
https://beta.domain.com it should redirect to https://www.domain.com.
http://beta.domain.com it should redirect to https://www.domain.com.
如果用户类型
http://www.domain.com it should redirect to https://www.domain.com
http://domain.com it should redirect to https://www.domain.com
如果用户类型
http://www.domain.com it should redirect to https://www.domain.com
http://domain.com it should redirect to https://www.domain.com
提前谢谢。
任何帮助都将不胜感激
提前感谢。这不是条件应该做的吗?它检查HTTPS是否关闭,只有在关闭后才会发生重定向。如果使用HTTPS,则不应重定向,否则将导致无止境的重定向 如果您总是希望主机名为
www.domainname.com
,则应将其作为附加条件添加。例如:
<rule name="Force HTTPS and host name: www.domainname.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" negate="true" pattern="^ON$" />
<add input="{HTTP_HOST}" negate="true" pattern="^www\.domainname\.com$" />
</conditions>
<action type="Redirect" url="https://www.domainname.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
如果
HTTPS
在上为非或HTTP\u主机
为非www.domainname.com
它将重定向。只有当两者都为真时,它才不会重定向。谢谢马可,我添加了你的帮助!!!。但它不能满足我的要求。请在我的主要问题中检查一下我的要求。我已经更新了更清晰的需求部分。提前感谢。我认为它满足了您的所有要求,除了您的第一个,但这是由于HTTPS的性质。只有当您的SSL证书是*.domainname.com
的通配符证书,或者是www.domainname.com
和beta.domainname.com
的多域证书时,您的第一个要求才能起作用。如果您的证书仅对www.domainname.com
有效,则当您打开https://beta.domainname.com
。你或IIS对此无能为力。