Change to 404 page to obtain the full url of the page generating the error
Change to 404 page to obtain the full url of the page generating the error
This enhancement is associated to the request submitted by HCA in this EE Jira Ticket:
http://jira.dotmarketing.net/browse/EE-4222
The change consist in include the url of the page that throws the 404 error. To do that we need to include this parameter "&ep_error_uri="+ep_error_uri" in the url dispatcher where the ep_error_uri is obtain from this request attribute ("javax.servlet.forward.request_uri")
Here is the current code (Line 80 to line 90 of this file /dotCMS/portal/404.jsp)
// if we have virtual link and page exists, redirect or forward
if(UtilMethods.isSet(pointer) ){
if (pointer.startsWith("/")) {
Logger.debug(this, "cms404Page forwarding to relative path: " + pointer);
request.getRequestDispatcher(pointer).forward(request, response);
} else {
pointer = pointer + "?ep_originatingHost="+ep_originatingHost+"&ep_errorCode="+ep_errorCode;
Logger.debug(this, "cms404Page redirecting to absolute path: " + pointer);
response.sendRedirect(pointer);
}
return;
}
And here is how should look the code with the changes applied
// if we have virtual link and page exists, redirect or forward
String ep_error_uri = (String)request.getAttribute("javax.servlet.forward.request_uri");
if(UtilMethods.isSet(pointer) ){
if (pointer.startsWith("/")) {
Logger.debug(this, "cms404Page forwarding to relative path: " + pointer);
request.getRequestDispatcher(pointer+ "?ep_originatingHost="+ep_originatingHost+"&ep_errorCode="+ep_errorCode+"&ep_error_uri="+ep_error_uri).forward(request, response);
} else {
pointer = pointer + "?ep_originatingHost="+ep_originatingHost+"&ep_errorCode="+ep_errorCode+"&ep_error_uri="+ep_error_uri;
Logger.debug(this, "cms404Page redirecting to absolute path: " + pointer);
response.sendRedirect(pointer);
}
Dean see here. http://jira.dotmarketing.net/browse/EE-4222
Working as it should: only in the case of an "all hosts" vanity url that has a complete (not relative), path to the error page... then you see: ep_originatingHost=practicewithus.com&ep_errorCode=404
Added Documentation: http://dotcms.com/docs/2.0/CustomErrorPages