【问题标题】:How to create a rule that passes only the Request Path - urlrewritefilter如何创建仅通过请求路径的规则 - urlrewritefilter
【发布时间】:2014-11-05 05:22:46
【问题描述】:

由于我们在页面中使用 ajax,我们需要为来自 Ajax Prerender 服务的搜索机器人请求提供服务。

为此,我创建了一个规则来修改抓取请求。 <OUR_DOMAIN>/stocks?_escaped_fragment_= 转换为 http://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f/stocks

我使用了以下规则:

<rule>
        <name>escaped_fragment</name>
        <!--<condition type="request-filename" operator="notfile"/>-->
        <condition type="query-string" operator="equal">.*escaped_fragment.*</condition>
        <from>(.*)$</from>
        <to type="proxy" last="true" qsappend="true">http://www.MY_SEO_SERVER.com/TOKEN_e291b9f78$1</to>
    </rule>

问题是它生成了错误的 URL:http://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f/stockshttp://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f

希望获得有关如何正确构建规则的建议。

我正在使用 urlrewritefilter - 4.0.3

日志:

DEBUG|http-apr-8080-exec-2|o.t.w.f.u.u.ServerNameMatcher | looking for hostname match on current server name localhost
DEBUG|http-apr-8080-exec-2|o.t.w.f.u.UrlRewriteFilter    | checking for status path on /stocks
DEBUG|http-apr-8080-exec-2|o.t.w.f.urlrewrite.UrlRewriter| processing request for /stocks
DEBUG|http-apr-8080-exec-2|o.t.w.f.urlrewrite.RuleBase   | escaped_fragment (rule 0) run called with /stocks
DEBUG|http-apr-8080-exec-2|o.t.w.f.urlrewrite.RuleBase   | matched "from"
DEBUG|http-apr-8080-exec-2|o.t.w.f.urlrewrite.Condition  | evaluating "_escaped_fragment_=" against .*escaped_fragment.*
DEBUG|http-apr-8080-exec-2|o.t.w.f.urlrewrite.RuleBase   | conditions match
DEBUG|http-apr-8080-exec-2|o.t.w.f.u.s.MatcherReplacer   | found 1
DEBUG|http-apr-8080-exec-2|o.t.w.f.u.s.MatcherReplacer   | replaced sb is http://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f/stocks
DEBUG|http-apr-8080-exec-2|o.t.w.f.u.s.MatcherReplacer   | found 1
DEBUG|http-apr-8080-exec-2|o.t.w.f.u.s.MatcherReplacer   | replaced sb is http://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f
DEBUG|http-apr-8080-exec-2|o.t.w.f.u.RuleExecutionOutput | needs to be 
proxied from http://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f/stockshttp://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f
DEBUG|http-apr-8080-exec-2|o.t.w.f.urlrewrite.UrlRewriter| rule is last
 INFO|http-apr-8080-exec-2|o.t.w.f.u.RequestProxy        | execute, 
target is http://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f/stockshttp://www.MY_SEO_SERVER.com/MY_TOKEN_e291b9f
 INFO|http-apr-8080-exec-2|o.t.w.f.u.RequestProxy        | response commit state: false
 INFO|http-apr-8080-exec-2|o.t.w.f.u.RequestProxy        | checking url
 INFO|http-apr-8080-exec-2|o.t.w.f.u.RequestProxy        | seting up the host configuration
 INFO|http-apr-8080-exec-2|o.t.w.f.u.RequestProxy        | config is HostConfiguration[host=http://www.MY_SEO_SERVER.com]
 INFO|http-apr-8080-exec-2|o.t.w.f.u.RequestProxy        | setting proxy request parameter:connection, value: keep-alive

【问题讨论】:

    标签: java tomcat proxy tuckey-urlrewrite-filter


    【解决方案1】:

    这似乎是 UrlRewriteFilter 的一个错误。将“/”添加到并成功了。

    这是最终规则

    <rule>
            <name>escaped_fragment</name>
            <!--<condition type="request-filename" operator="notfile"/>-->
            <condition type="query-string" operator="equal">.*escaped_fragment.*</condition>
            <from>^/(.*)$</from>
            <to type="proxy" last="true" qsappend="true">http://www.MY_SEO_SERVER.com/TOKEN_e291b9f78/$1</to>
        </rule>
    

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-22
      • 1970-01-01
      • 2019-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多