Customize 404 Error Page
This section walks you through the process of replacing the default SearchBlox error pages with your own custom HTML page. Once set up, users will see your error page instead of the server's default output when they hit a 404 (page not found) or 403 (access denied) error.
Steps to Customize Error Page in SearchBlox
-
Prepare Custom Error Page
Create an HTML file named 404.html with your custom error content
Place the file in both locations:
<SEARCHBLOX_INSTALLATION_PATH>/webapps/ROOT/
<SEARCHBLOX_INSTALLATION_PATH>/webapps/ROOT/ -
Stop SearchBlox Server
sudo systemctl stop searchblox -
Edit the following configuration files:
<SEARCHBLOX_INSTALLATION_PATH>/etc/webdefault.xml
<SEARCHBLOX_INSTALLATION_PATH>/webapps/ROOT/WEB-INF/web.xml -
Add the following code entries into each configuration file. These entries instruct the web server to display your custom 404.html page whenever a visitor encounters a 404 or 403 error, instead of showing the default server error output.
Sample code snippet from webdefault.xml
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/404.html</location>
</error-page>
Sample code snippet from web.xml
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/admin/errorpage.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/404.html</location>
</error-page>
<security-constraint>
<web-resource-collection>
- Please start SearchBlox and test the custom 404 page by giving an incorrect URL as SearchBlox endpoint.
Please note that there is only one custom HTML page that can be used as a 404 error page.sudo systemctl start searchblox
Verification Steps
Once SearchBlox has restarted, follow these steps to confirm that your custom error page is working correctly:
- Trigger a 404 error by accessing a non-existent URL
- Verify your custom page appears instead of the default error page
- Repeat verification for 403 errors if configured
Updated 9 days ago
