【问题标题】:Setting up URL Rewrite rule for a specific domain SEO为特定域 SEO 设置 URL 重写规则
【发布时间】:2016-10-17 23:10:13
【问题描述】:

在谷歌上有以下网址

www.domain.ch/House/rent

所以现在我的页面现在有多种语言版本,并且我现在在 url 中有语言,它看起来像这样

www.domain.ch/en/house/rent

所以我会在web.config中用url rewrite重定向所有旧链接,但是我找不到匹配条件来确定url中是否有语言。

我的角色:

<rule name="mydomain.com" >
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="^(localhost:3005/|localhost:3005/)$" />
  </conditions>
 <action type="Redirect" url="http://localhost:3005/de/{R:1}" logRewrittenUrl="true" />
</rule>

感谢您的帮助!

【问题讨论】:

    标签: asp.net asp.net-mvc-3 iis url-rewriting asp.net-mvc-routing


    【解决方案1】:
    <rule name="mydomain.com" stopProcessing="true" >
      <match url="(.*)" />
      <conditions>
        <!-- redirect only if the URL doesn't contain /en/ or /de/ already (negate = true)-->
        <add input="{URL}" pattern="/en/|/de/" negate="true" />
      </conditions>
      <action type="Redirect" url="de/{R:1}"  />
    </rule>
    

    【讨论】:

    • 很酷,它可以工作,我想我必须将 domain.ch/de 放在重定向 url 中。但它太棒了!现在我只有 bundle url 的问题,因为它现在看起来也适用于 ..de/bundles/jquery ......但这不是一个大问题......谢谢
    • 用同样的想法来否定这些。
    猜你喜欢
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 2021-12-30
    • 2011-01-21
    • 2015-03-25
    相关资源
    最近更新 更多