Java Jetty配置将所有404重定向到主页
谷歌已经将一些旧的URL缓存到网站上不再存在的页面上。我想将404页重定向到主页 我安装了jetty,jetty/webapps中安装了ROOT.war文件。ROOT.war文件包含一个WEB-INF/WEB.xml文件,其中包含以下内容:Java Jetty配置将所有404重定向到主页,java,jetty,Java,Jetty,谷歌已经将一些旧的URL缓存到网站上不再存在的页面上。我想将404页重定向到主页 我安装了jetty,jetty/webapps中安装了ROOT.war文件。ROOT.war文件包含一个WEB-INF/WEB.xml文件,其中包含以下内容: <error-page> <error-code>404</error-code> <location>/</location> </error-page> 但这一个没
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
但这一个没有,只是给出了一个404错误:
http://mysite.com/directoryDoesntExist/pageDoesntExist.html
有没有办法将所有404配置为进入主页?我可以在jetty/contexts目录中执行此操作吗 要使用org.mortbay.jetty.handler.MovedContextHandler: 机器人将使用标头301重定向更新缓存google一个想法是:
<error-page>
<error-code>404</error-code>
<location>/error404.html</location>
</error-page>
(如中所述)谢谢。但我不清楚如何配置它来处理大量URL。我必须为每个URL创建一个新的上下文文件,这太疯狂了。一定有更好的办法。您能否提供一个示例,例如将
/directorydesntextest
目录中的所有地址重定向到主页?
<error-page>
<error-code>404</error-code>
<location>/error404.html</location>
</error-page>
<html>
<head><title>Redirecting...</title></head>
<body>
<script>
document.location.href="/";
</script>
</body>
</html>