【问题标题】:URLrewriteFilter tuckey redirectURLrewriteFilter 塔基重定向
【发布时间】:2013-02-03 18:08:45
【问题描述】:

我正在尝试使用UrlRewriteFilter 进行重定向。由于我们一直在移动服务器和基础架构以开发我们的内部云解决方案,因此我们计划大量使用这些解决方案。

我的问题是我有一个类似的网址

https://google.com/web-app/servlet?请求参数和值

我需要将所有具有特定参数值的URLs 重定向到不同的服务器。

这样的网址:

https://google.com/administrator/servlet/ej.processOrder?sec=100&geo=appointment&cus=dubai

如果参数中包含cus=dubai,需要重定向到

https://hotmail.com/servlet/ej.processOrder?sec=100&geo=appointment&cus=dubai

我尝试了以下方法,但似乎不起作用

<urlrewrite use-query-string="true">
    <rule match-type="wildcard">
        <name>Redirect requests to cases</name>
        <description></description>
        <from>/administrator/servlet/**?**</from>
        <to type="redirect" last="true">http://hotmail.com:8080/servlet/$1?&amp;cus=dubai&amp;$2&amp;$3&amp</to>
    </rule> 
</urlrewrite>

感谢您的帮助。

【问题讨论】:

    标签: tuckey-urlrewrite-filter


    【解决方案1】:

    您需要使用query-string 并确保它符合特定条件。

    据我所知,你会想要这样的东西:

    <condition name="query-string" operator="equal">*cus=dubai*</condition>
    

    您需要为每个不同的参数设置一个规则。一条完整的规则如下所示:

    <urlrewrite use-query-string="true">
    
        <rule match-type="wildcard">
            <name>Cus = dubai</name>
            <from>/administrator/servlet/*</from>
            <condition name="query-string" operator="equal">*cus=dubai*</condition>
            <to type="redirect" last="true">https://hotmail.com/servlet/ej.processOrder?sec=100&geo=appointment&cus=dubai</to>
        </rule> 
    
        <!-- other rules go here -->
    
    </urlrewrite>
    

    【讨论】:

      【解决方案2】:

      条件应该是“类型”而不是“名称”,如:

      <condition type="query-string" operator="equal">*cus=dubai*</condition>
      

      【讨论】:

      • 您的回答没有解释任何内容。它看起来与花哨的答案非常相似。
      【解决方案3】:

      好问题,对于我想象中经常发生的情况,在我看来,manual 中没有很好地记录它。

      以下对我有用 -

      <rule>
      <condition type="query-string">foo=123&amp;bar=456</condition>
      <from>/index.jsp</from>
      <to type="permanent-redirect" last="true">https://somehwere-else.com/blah/blah/</to>
      </rule>
      

      所以这应该适合你 -

      <rule>
      <name>Redirect requests to cases</name>
      <condition type="query-string">sec=100&amp;geo=appointment&amp;cus=dubai</condition>
      <from>/administrator/servlet</from>
      <to type="permanent-redirect" last="true">http://hotmail.com:8080/servlet/sec=100&amp;geo=appointment&amp;cus=dubai</to>
      </rule> 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-18
        • 1970-01-01
        • 2018-12-24
        • 2012-12-29
        相关资源
        最近更新 更多