【问题标题】:Rewrite rule works perfect, but I don't want to rewrite www重写规则完美,但我不想重写 www
【发布时间】:2014-01-08 04:36:26
【问题描述】:

我有这个重写规则,将 demo.mydomain.com 重写为 mydomain.com/myform.aspx?url=demo。

 <rewrite>
 <rules>
 <rule name="domain redirect" stopProcessing="true">
  <match url="^(.*)$" />
  <conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^(.+)\.mydomain\.com$" />
  </conditions>
   <action type="Rewrite" url="{REQUEST_URI}/myform.aspx?url={C:1}" appendQueryString="true" />
 </rule>
</rules>
</rewrite>

我的问题是http://www.mydomain.com 也被重写了。如何在我的重写规则中排除 www?

【问题讨论】:

    标签: c# asp.net url web-applications url-rewriting


    【解决方案1】:
     <add input="{HTTP_HOST}" pattern="^[^(www)](.+)\.mydomain\.com$" />
    

    【讨论】:

    • 非常感谢。你能解释一下吗?你的意思是把我的比赛网址改成那个吗?我试过了,但后来一切都链接到 www.mydomain.com。
    • 啊,我读错了,并将正则表达式添加到错误的行。已更新。
    • 谢谢,但更接近了。我是否需要更改它以将正确的值转换为 ={C:1}" ="{REQUEST_URI}/myform.aspx?url={C:1}"
    • 当我在 IIS 中测试“test.mydomain.com”的规则时,c:1 返回“est”
    • 我用这个肮脏的把戏解决了它: ^([^(www)])(.+)\.crmcatch\.com$ 然后 ="{REQUEST_URI}/myform.aspx?url= {C:1}{C:2}""
    猜你喜欢
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2015-07-10
    • 2011-09-18
    相关资源
    最近更新 更多