【问题标题】:urlrewritefilter not redirectingurlrewritefilter 不重定向
【发布时间】:2018-08-08 19:45:22
【问题描述】:

我正在尝试使用 urlrewritefilter 实现看起来非常简单的重定向,如下所示,但它没有重定向。

<rule> 
<from>/?industry_id=22</from> 
<to type="permanent-redirect">/industry/22/publishing</to> 
</rule> 

其他规则也可以。有什么建议么?

谢谢!

【问题讨论】:

  • 什么是未重定向的完整 URL?另外,你确定上面的另一个规则没有被捕获吗?
  • 它是domain.com/?industry_id=22。它现在只在我的本地主机上,所以我不能给你一个实时 URL。我把它作为消除这种可能性的第一条规则。
  • 我想也许我需要将参数分解成一个条件,所以我尝试了这个&lt;rule&gt; &lt;condition type="query-string"&gt;industry_id=22&lt;/condition&gt; &lt;from&gt;/&lt;/from&gt; &lt;to type="permanent-redirect"&gt;/industry/22/publishing&lt;/to&gt; &lt;/rule&gt; 也不起作用。
  • 我遇到了同样的问题并使用&lt;rule&gt; &lt;condition type="parameter" name="fruit"&gt;&lt;/condition&gt; &lt;from&gt;/&lt;/from&gt; &lt;to type="permanent-redirect"&gt;/myUrl/%{parameter:fruit}&lt;/to&gt; &lt;/rule&gt; 解决了它,效果很好。上面的代码有助于@Jim。但参数名称不包含任何特殊字符。抛出 java.lang.IllegalArgumentException: URLDecoder: 转义 (%) 模式中的非法十六进制字符 - %%7 有人可以帮助我吗?

标签: java url-rewriting xml-parsing tuckey-urlrewrite-filter


【解决方案1】:

我认为问题在于您的“From”被解释为正则表达式。尝试转义特殊字符,例如:

<rule>
  <from>/\?industry_id\=22</from>
  <to type="permanent-redirect">/industry/22/publishing</to>
</rule>

让我们知道它是否有效! :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多