core icon indicating copy to clipboard operation
core copied to clipboard

Change to 404 page to obtain the full url of the page generating the error

Open gabbydotCMS opened this issue 14 years ago • 4 comments

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

gabbydotCMS avatar May 07 '12 17:05 gabbydotCMS

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); }

oswaldogallango avatar May 11 '12 21:05 oswaldogallango

Dean see here. http://jira.dotmarketing.net/browse/EE-4222

jtesser avatar Jul 05 '12 12:07 jtesser

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

DeanGonzalez avatar Aug 14 '12 20:08 DeanGonzalez

Added Documentation: http://dotcms.com/docs/2.0/CustomErrorPages

DeanGonzalez avatar Aug 14 '12 21:08 DeanGonzalez