java - Tuckey URL 重写中的转义问号(XML/Regex)

标签 java regex url-rewriting tuckey-urlrewrite-filter

我想永久重定向

/?industry_id=3 to /industry/3/athletics

我尝试了规则:

 <rule>
    <from>/?industry_id=3$</from>
    <to type="permanent-redirect" last="true">/industry/3/athletics</to>
 </rule>

 <rule>
    <from>/&#63;industry_id=3$</from>
    <to type="permanent-redirect" last="true">/industry/3/athletics</to>
 </rule>


 <rule>
    <from>/\\?industry_id=3$</from>
    <to type="permanent-redirect" last="true">/industry/3/athletics</to>
 </rule>

 <rule>
    <from>/\?industry_id=3$</from>
    <to type="permanent-redirect" last="true">/industry/3/athletics</to>
 </rule>

但没有成功。

我尝试过这个:

 <rule match-type="regex">
    <note>Request page is deprecated</note>
    <condition type="query-string">industry_id=3</condition>
    <from>/</from>
    <to type="permanent-redirect" last="true">/industry/3/athletics</to>
 </rule>

它适用于重写,但由于我猜测的其他规则,我得到了“太多重定向”,即使设置了参数last=“true”

最佳答案

这看起来很奇怪。以下内容对我有用:

<rule>
  <condition type="query-string">page=download</condition>
  <from>/</from>
  <to type="permanent-redirect" last="true">/downloads</to>
</rule>

正如您所提到的,您必须有其他一些干扰规则。

关于java - Tuckey URL 重写中的转义问号(XML/Regex),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14879308/

相关文章:

.htaccess - 使用 htaccess 重写规则的多域重定向

ruby - 如何使用 rack-rewrite 重写到不同的域?

c++ - 如何重写这个c++简单代码?

java - 未封闭的字符类(正则表达式)

java - 为什么第 3 行没有发生动态绑定(bind)?

javascript - 在 javascript 中使用正则表达式查找特定单词

mysql - 正则表达式按顺序查找两个字符,在其他字符之间,忽略标点符号

java - jackson 根据类型反序列化

java - 具有多个源文件夹的 eclipse 项目的 build.gradle

ios - 如何在 objective-c 中用给定的字符串替换正则表达式的组1