第一步是要有正确的设置错误处理程序,在那里你是在响应状态设置正确的错误代码。
样品用于错误处理程序404
配置404.jsp
<%
if (com.day.cq.wcm.api.WCMMode.fromRequest(request) != com.day.cq.wcm.api.WCMMode.DISABLED) {
%>
<%@include file="/libs/sling/servlet/errorhandler/404.jsp"%>
<%
} else {
response.setStatus(404);
}
%>
下一步是具有阿帕奇/调度程序配置成加载(在虚拟主机config配置)正确的错误的文件。这样的错误页面的正确装载委托给了Apache /调度 -
<LocationMatch "^/content/secondapp/country-1/en/.*$">
ErrorDocument 404 "/country-1/not-found.html"
ErrorDocument 500 "/country-1/error.html"
</LocationMatch>
<LocationMatch "^/content/secondapp/country-2/en/.*$">
ErrorDocument 404 "/country-2/not-found.html"
ErrorDocument 500 "/country-2/error.html"
</LocationMatch>
<LocationMatch "^/content/secondapp/country-3/en/.*$">
ErrorDocument 404 "/country-3/not-found.html"
ErrorDocument 500 "/country-3/error.html"
</LocationMatch>
<LocationMatch "^/content/secondapp/country-4/en/.*$">
ErrorDocument 404 "/country-4/not-found.html"
ErrorDocument 500 "/country-4/error.html"
</LocationMatch>
上述的结构的基础上,短网址,其中在图案 /content/secondapp/country-x/en/.*
缩短to /country-4/en/.*
和每个网站都有自己的页面的error.html和not-found.html