We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« Back to Blogs

Set up Error Pages In Liferay

Set up Error Pages In Liferay


We are creating public/private pages in Liferay and add content on that pages.So all page has some url and it will show on navigation and hide that pages on navigation.We can direct page URL and go to that page.

If in case some page not exist on portal it will redirect to error page and if we want to add our own 404 error page then liferay provide way to redirect user to specific page or html content if in case of page not found.

If we are doing deployment site and at that time site will down then we need to show users that “We are on maintenance”.

We are using liferay portal ext property to redirect user to specific page or html page.In this article we will discuss ways to set 404 page on liferay portal.

Set 404 page not found in Liferay:

We can set up 404 page in multiple ways so we are adding some ways to set up 404 page.

1. Set portal ext property in liferay portal



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


Note: If you have already created public page in liferay then you can give direct page url in portal ext property.

  1. Restart your liferay portal.Its done You will redirect to this HTML page if page is not exit on your portal.

2. Redirect user to custom 404 page

  1. First of all create 404 page not found on your Liferay portal.
  2. Set portal ext property in Liferay portal.
    Layout.friendly.url.page.not.found = /html/portal/404-page-not-found.jsp
  3. You need to write code to redirect user to 404-page-not-found page.
    private static final String 404_PAGE_NOT_FOUND_URL = "/404-page-not-found"; 
    LayoutSet layoutSet = (LayoutSet)request.getAttribute(WebKeys.VIRTUAL_HOST_LAYOUT_SET);
    boolean 404Exists = true;
    try {
    	LayoutLocalServiceUtil.getFriendlyURLLayout(layoutSet.getGroupId(), lay  outSet.isPrivateLayout(), 404_PAGE_NOT_FOUND_URL);
    } catch (NoSuchLayoutException e) {
    	404Exists = false;
    <c:if test="<%= 404Exists %>">
    <c:import url='<%= PortalUtil.getPortalURL(request) + 404_PAGE_NOT_FOUND_URL + ";jsessionid=" + session.getId() %>'/>
  4. Now need to add this jsp in you Liferay tomcat -> html -> error path
  5. Open that 404 page not found page and add web content which you want to display.
  6. It’s done. Hit page url which is not exist.You will redirect to custom 404 page.
Set up Error pages In Liferay Via apache:


  1. Create html for each error page.
  2. Add Error document in apache conf file.
    ErrorDocument 404 /error.html
    ErrorDocument 402 /error.html
    ErrorDocument 403/error.html
    ErrorDocument 404/error.html
    ErrorDocument 500/error.html
  3. Restart your apache server.
contact-us Request a callback WhatsApp