掲示板

Liferay 7 - Custom "not found (404 error)" page

6年前 に Marc Roger によって更新されました。

Liferay 7 - Custom "not found (404 error)" page

New Member 投稿: 1 参加年月日: 17/05/11 最新の投稿
Hi,

I'm developing with Liferay 7 and I would like to create a custom page for the 404 error.
In Liferay 6.2 this is solved by adding this line in the portal-ext.properties file:
layout.friendly.url.page.not.found=/custom-error-page

This property doesn't works on Liferay 7. How should I configure this redirect on my portal?

Thanks in advance.
thumbnail
6年前 に Yannis Sinadinos によって更新されました。

RE: Liferay 7 - Custom "not found (404 error)" page

Junior Member 投稿: 39 参加年月日: 17/03/20 最新の投稿
Hi,
I have the same issue and the "layout.friendly.url.page.not.found=/custom-error-page" doesn't work in Liferay 7 GA4.
Did you find any solution?

Thank you,
Yannis
thumbnail
5年前 に Mayur Mulani によって更新されました。

RE: Liferay 7 - Custom "not found (404 error)" page

New Member 投稿: 3 参加年月日: 17/03/02 最新の投稿
Hi Marc,

It can be resolved by multiple ways.

Option 1

layout.friendly.url.page.not.found=/web/guest/page-not-found.

include mentioned above property in portal-ext.properties file. Create one public page page-not-found and make your custom design for this page .

Option 2 : 

layout.friendly.url.page.not.found=/html/portal/error/404-page-not-found.jsp

include mentioned above propery in portal-ext.properties file. Create one jsp file on mentioned path.  Make some rewrite rule in that jsp file.  By making your own custom redirect logic you can redirect page as you want.

<%@ page import="com.liferay.portal.kernel.util.PortalUtil" %>

<%! private static final String PAGE_404_URL = "/page-404-not-found"; %>

<c:import url='<%= PortalUtil.getPortalURL(request) + PAGE_404_URL%>'/>​​​​​​​


Option 3 :

Override code.jsp file (Create core jsp hook). In liferay dxp error pages being handled by code.jsp which is residing under ROOT/errors/code.jsp. This logic you can find it in web.xml (ROOT/webapps/WEB-INF/web.xml)

<error-page>
        <error-code>404</error-code>
        <location>/errors/code.jsp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/errors/code.jsp</location>
    </error-page>


So make custom jsp bag hook to override code.jsp file where you can handle 403, 500  and rest of the error pages as well. you can put your own design or redirect page from this jsp file according to your requirement.


Note :  Option 1 wont work for all the scenarios. It will be failed for some of the scenarios.

Thanks,
Mayur Mulani