【发布时间】:2011-10-27 13:17:52
【问题描述】:
我们已经通过tomcat rewrite.xml文件为java应用定义了url规则。
<rule>
<condition name="host" operator="equal">example-laboratories.pt</condition>
<from>[^pt]/(.*)$</from>
<to type="redirect">http://example-laboratories.pt/pt/$1</to>
</rule>
这在我们请求 URL http://example-laboratories.pt url 时有效,但如果用户请求 http://example-laboratories.pt/pt,我需要重定向到 http://example-laboratories.pt/pt。现在上面的规则重定向到http://example-laboratories.pt/pt/pt(注意末尾的附加'pt')。
【问题讨论】:
-
我没有完全了解您想要什么重写,所以我无法提出解决方案,但这肯定是正则表达式问题。 (
from与您的预期不符……)
标签: java regex tomcat url-rewriting