【问题标题】:wildcard redirect with url rewrite by web.config通配符重定向,通过 web.config 重写 url
【发布时间】:2011-08-25 23:00:20
【问题描述】:

我正在使用 web.config 中的 url 重写功能来重定向我的子域。这是我的规则:

   <rule name="redirect_page">
      <match url=".*" ignoreCase="false" negate="false" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www\." negate="true" />
        <add input="{HTTP_HOST}" pattern="^([\w\-]+)\.mySite\.com$" />
      </conditions>
      <action type="Rewrite" url="profile.aspx?name={C:1}" />
    </rule>

这很好用: http://myUser.mySite.com 重定向到 http://myUser.mySite.com/profile.aspx?name=myUser

但是

http://myUser.mySite.com/image/myImage.jpg 重定向到 http://myUser.mySite.com/profile.aspx?name=myUser

=> 我想要什么: http://myUser.mySite.com/image/myImage.jpg 重定向到 http://myUser.mySite.com/image/myImage.jpg

有什么想法吗?

【问题讨论】:

    标签: url-rewriting web-config


    【解决方案1】:

    这有点棘手,但这是解决方案:

        <rule name="SubDomainDoNothing" stopProcessing="true">
          <match url="(.+)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.plugandtable\.com$" />
          </conditions>
          <action type="Rewrite" url="{R:1}" />
        </rule>
    
        <rule name="SubDomainRedirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.plugandtable\.com$" />
          </conditions>
          <action type="Rewrite" url="profile.aspx?name={C:1}" />
        </rule>
    

    【讨论】:

      猜你喜欢
      • 2022-11-24
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多