URL重写到另一个子域

时间:2019-02-07 22:44:04

标签: asp.net iis url-rewriting

我正在尝试创建要发送的URL重写规则:

  

www.mycompany.com/file.aspx?someQueryString
  或
  www.mycompany.com/fileXYZ.aspx?someQueryString

  

www.subdomain.mycompany.com/file.aspx?someQueryString
  或
  www.subdomain.mycompany.com/fileXYZ.aspx?someQueryString

我写了这个规则:

<rule name="MyPageRewrite" stopProcessing="true"> <match url="(.*)(file[a-zA-Z]*\.aspx)" /> <action type="Rewrite" url="http://subdomain.mycompany.com/{R:1}" /> </rule>

match表达式似乎起作用,但是目的地不起作用?怎么了?

1 个答案:

答案 0 :(得分:0)

感谢Lex Li,我对您提供的测试aspx文件做了很多测试,发现一条有效的规则:

<rule name="MyPageRewrite" stopProcessing="true">
   <match url="(.*)(file[a-zA-Z]*\.aspx)" />
   <action type="Redirect" redirectType="Found" url="http://subdomain.mycompany.com/{R:0}" appendQueryString="true"/> 
</rule>
相关问题