gpt4 book ai didi

java - 如何创建仅传递请求路径的规则 - urlrewritefilter

转载 作者:行者123 更新时间:2023-11-28 23:34:01 26 4
gpt4 key购买 nike

由于我们在页面中使用了 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

最佳答案

这似乎是 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>

关于java - 如何创建仅传递请求路径的规则 - urlrewritefilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26706430/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com