[英]IIS URL Rewrite redirect
I'm trying to find out how to write IIS URL Rewrite rule to redirect by the following rule: 我试图找出如何编写IIS URL重写规则以通过以下规则进行重定向:
For example: 例如:
s1.mysite.com/mypage.aspx?p=1
should be redirected to www.mysite.com/mypage.aspx?p=1
. s1.mysite.com/mypage.aspx?p=1
应该重定向到www.mysite.com/mypage.aspx?p=1
。
But this redirection rule, should only work if URL starts with one of the following: 但是,仅当URL以下列之一开头时,此重定向规则才有效:
"s1", "s2", "s5" and contains ".aspx". “ s1”,“ s2”,“ s5”并包含“ .aspx”。
I started to write some Regex pattern for that "(s1\\.|s2\\.|s5\\.)+(.)*(\\.aspx)+"
, but actually, I don't even know if I'm on correct way. 我开始为
"(s1\\.|s2\\.|s5\\.)+(.)*(\\.aspx)+"
写一些正则表达式模式,但实际上,我什至不知道我是否在正确的方法。
After I will have the regex
pattern, how I can tell IIS
to redirect to exactly same url, just instead s1|s2|s5
it must be www
. 获得
regex
模式后,如何告诉IIS
重定向到完全相同的url,只是s1|s2|s5
必须为www
。
This should get the job done: 这应该完成工作:
<rewrite>
<rules>
<rule name="Redirect s1, s2 and s5 subdomains" stopProcessing="true">
<match url="\.aspx$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(s1|s2|s5)\.mysite\.com$" />
</conditions>
<action type="Redirect" url="http://www.mysite.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.