我想转发与该模式匹配的所有 URL:
http://localhost:8080/docs/view.php?fDocumentId=([0-9]+)
至:
http://localhost:8080/alfresco/service/org/docs/redirect/document/properties/$1
这是在 tomcat 上,有两个主要的 webapps 正在加载:“docs”和“alfresco”。
为简单起见,我们的旧旧应用程序(基于 LAMP)的所有 URL 都以 /docs 作为路径的第一部分,与新应用程序相同。我转发到 /alfresco 的原因是因为我开发了一个 webscript 来将旧 URL 解析为新 URL 并执行另一个重定向回 /docs,但这与这个问题无关。
新系统已经加载了URLRewriteFilter,但是缺少需要放入 webapps/docs/WEB-INF/web.xml 的 google 代码站点(我添加)中提到的以下特定代码:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
然后,我将以下规则添加到与 web.xml 位于同一目录中的 urlrewrite.xml:
<rule>
<from>^/docs/view.php?fDocumentId=([0-9]+)</from>
<to>/alfresco/service/org/docs/redirect/document/properties/$1</to>
</rule>
当我试图去类似的东西时,我得到了 404http://localhost:8080/docs/view.php?fDocumentId=12345