第一步是要有正確的設置錯誤處理程序,在那裏你是在響應狀態設置正確的錯誤代碼。
樣品用於錯誤處理程序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