如何使用tuckey urlrewrite重定向url

时间:2013-11-12 09:58:25

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

我有一个名为'index.html'的网页,我可以使用'http://example.com/index.html'来访问它。

我打算做的是使用“http://example.com/index.htm”访问'index.html';如果使用“http://example.com/index.html”,则会返回404。

我正在使用tuckey urlrewrite,这是我的配置xml:

<rule>
    <from>^/(.*).htm$</from>
    <to>/$1.html</to>
</rule>

<outbound-rule>
    <from>^/(.*).html$</from>
    <to >/$1.htm</to>
</outbound-rule>

部署后,我可以使用“http://example.com/index.htm”访问我的index.html,但是当我使用“http://example.com/index.html”时,它仍然可以访问我的index.html。

在请求* .html时,如何让服务器返回404,我该怎么做?非常感谢!

1 个答案:

答案 0 :(得分:0)

尝试为规则制定<set type="status">404</set>添加/.*.html$