Redirect Sitecore重定向模块正则表达式模式匹配

Redirect Sitecore重定向模块正则表达式模式匹配,redirect,sitecore,sitecore7,Redirect,Sitecore,Sitecore7,使用Sitecore 7的301重定向模块时,我在建立Sitecore重定向模块中使用的正确请求表达式和源值时遇到问题。我有一个示例url,它通常获取我希望重定向到站点主页的请求 示例url请求在url末尾都包含exite.com: https://www.example.com/products/foods/apples/excite.com https://www.example.com/products/foods/oranges/excite.com https://www.exampl

使用Sitecore 7的301重定向模块时,我在建立Sitecore重定向模块中使用的正确请求表达式和源值时遇到问题。我有一个示例url,它通常获取我希望重定向到站点主页的请求

示例url请求在url末尾都包含exite.com:

https://www.example.com/products/foods/apples/excite.com
https://www.example.com/products/foods/oranges/excite.com
https://www.example.com/products/foods/pears/excite.com
我希望这些最后包含excite.com的请求被重定向到主页(),但我一辈子都无法解决这个问题。

我没有使用过,但使用过类似的模块。有两个问题需要解决

您需要使用模式匹配重定向创建重定向。您需要的正则表达式是“匹配以
/excite.com
结尾的任何请求”

*(/excite.com)$

另一个问题是Sitecore将url的
.com
部分视为扩展,然后过滤请求。您需要将
com
添加到允许的扩展列表中

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
      <preprocessRequest>
        <processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
          <param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, com</param>
        </processor>
      </preprocessRequest>      
    </pipelines>    
  </sitecore>
</configuration>

aspx、ashx、asmx、com
综上所述,如果您使用的是IIS重写模块,那么您可以在其中添加一条规则,该规则将在您访问Sitecore管道之前得到解析和重定向,因此您无需担心允许的扩展过滤器

<rules>  
  <rule name="Redirect excite.com" stopProcessing="true">
    <match url=".*(/excite.com)$" />
    <action type="Redirect" url="https://{HTTP_HOST}" appendQueryString="false" />
  </rule>
</rules>


如果还希望正则表达式与
匹配,请将其更改为
(excite.com)$|.*(/excite.com)$
http://ww.example.com/excite.com

您使用的是哪个重定向模块?市场上有几种,它们的工作方式都略有不同。我使用的是301重定向模块,这工作得很完美!1) 模式(尽管我需要将301重定向模块调整为^)2)添加com作为允许的扩展。