【问题标题】:use iis 8 to remove a section of a URL whilst keeping all other sections使用 iis 8 删除 URL 的一部分,同时保留所有其他部分
【发布时间】:2015-06-02 22:39:24
【问题描述】:

输入的网址是http://www.mywebsite.com/en-us/lookingtobuy/propertiesforsale.aspx?ppid=MD19863,我需要将网址重定向到http://www.mywebsite.com/lookingtobuy/propertiesforsale.aspx?ppid=MD19863

所以我需要删除en-us/

?ppid/ 之后的所有内容都是一个变量,因此编写的任何规则都需要允许它匹配输入的内容

【问题讨论】:

    标签: asp.net iis url-rewriting url-redirection


    【解决方案1】:

    这条规则应该有效:

    <rule name="remove en-US">
      <match url="^/en-US/(.*)" />
      <action type="Rewrite"
              url="http://{HTTP_HOST}/{R:1}" />
    </rule>
    

    如果你需要允许其他文化

    <rule name="remove culture">
      <match url="^/(\w{2}-\w{2})/(.*)" />
      <action type="Rewrite"
              url="http://{HTTP_HOST}/{R:2}" />
    </rule>
    

    {R:x} 是对规则模式的反向引用。对于第二条规则

    • {R:0} 将是 /en-us/lookingtobuy/propertiesforsale.aspx?ppid=MD19863
    • {R:1} 将是 en-us
    • {R:2} 将是 lookingtobuy/propertiesforsale.aspx?ppid=MD19863

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      相关资源
      最近更新 更多