Liferay portal runs and is configured as ROOT application with in tomcat sever.
By default, if tried to request a plugin in Liferay (say we have a theme plugin named as "error-theme"), a 404 Error is raised and the user is served Tomcat's default 404 error page as below:
To make your 404 page a bit more presentable, provide the user with a link back into your site, as well as hide the Tomcat version in use, you can easily add a custom 404 error page.
By default, if tried to request a plugin in Liferay (say we have a theme plugin named as "error-theme"), a 404 Error is raised and the user is served Tomcat's default 404 error page as below:
To make your 404 page a bit more presentable, provide the user with a link back into your site, as well as hide the Tomcat version in use, you can easily add a custom 404 error page.
Step 1:
Create a jsp name it 404.jsp, with below content:
The requested resource is not available. Please provide the correct URL or try again later.
<br/>
<a href="#" onclick="javascript:history.go(-1);">Go back to main site.</a>
Step 2:
Now create a new directory as error-theme/docroot/errors in Lifeay IDE and copy the above created 404.jsp to it.Step 3:
Last step is to add the below code to the web deployment descriptor (web.xml) of the plugin:
<error-page>
<error-code>404</error-code>
<location>/errors/404.jsp</location>
</error-page>
Now, when someone goes to the plugin link that does not exist, they get the custom 404 page we created.