0
我正面臨一些奇怪的問題。執行一個規則(最後一條規則)是在轉發之前將URL傳遞給次要的,這給了我404錯誤。URLRewriteFilter規則追加到URL 2次
的web.xml內容
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<!-- FORWARD dispatcher will keep on parsing requests through rule until
atleast one rule is applied . It sometime may lead into infinite loop
-->
<!-- <dispatcher>FORWARD</dispatcher> -->
</filter-mapping>
我的規則
<rule>
<name>DepreatedUrls</name>
<from>(/my/url2|/my/url3)</from>
<set type="status">410</set>
<to last="true">%{context-path}/error/410.html</to>
</rule>
<rule>
<name>AllRemainingRequests</name>
<note>
This rule will block all other requests and return http error
404 (not supported) and custom error message .
</note>
<from>(.*)</from>
<set type="status">404</set>
<to last="true">/error/410.html</to>
</rule>
所有其他規則正在執行的罰款。每條規則都是最後一條規則(last =「true」)。 但是,當最後一條規則被執行時,它會將請求轉發到 /error/410.html/error/410.html
我已經刪除了大部分規則定義以保持簡單。以下是調試日誌
Nov 20, 2012 12:31:10 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: AllRemainingRequests (rule 8) run called with /some-content
Nov 20, 2012 12:31:10 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
Nov 20, 2012 12:31:10 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.SetAttribute DEBUG: set Set status null 404 called
Nov 20, 2012 12:31:10 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.SetAttribute DEBUG: setting status
Nov 20, 2012 12:31:10 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs to be forwarded to /error/410.html/error/410.html
Nov 20, 2012 12:31:10 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: rule is last