Creating Custom Error Pages
Custom error pages replace the default server error messages with your own branded pages. This provides a better user experience when visitors encounter errors on your website such as broken links or server issues.
Accessing Custom Error Pages in DirectAdmin
- Log in to DirectAdmin.
- Navigate to Advanced Features.
- Click on Custom Error Pages.
- Select the error code you want to customize from the list.
Common Error Codes
- 400 Bad Request - The server could not understand the request.
- 401 Unauthorized - Authentication is required to access the resource.
- 403 Forbidden - The server understood the request but refuses to authorize it.
- 404 Not Found - The requested page or file does not exist.
- 500 Internal Server Error - A general server-side error occurred.
Creating a Custom 404 Page
- Create an HTML file named
404.html(or404.shtml) in yourpublic_htmldirectory. - Design the page to match your website's look and feel. Include helpful elements such as:
- Your website logo and navigation menu.
- A friendly message explaining the page was not found.
- A search bar to help visitors find what they need.
- Links to your homepage and popular pages.
- In DirectAdmin's Custom Error Pages section, select the 404 error.
- Enter the path to your custom page or paste the HTML content.
- Click Save.
Using .htaccess for Custom Error Pages
You can also configure custom error pages via your .htaccess file:
ErrorDocument 404 /404.html
ErrorDocument 403 /403.html
ErrorDocument 500 /500.html
Paths in ErrorDocument directives are relative to your document root. Ensure the error page files exist at the specified paths or visitors will see a plain text error instead.
Keep your custom error pages simple and lightweight. Avoid relying on external resources or complex PHP scripts that might themselves cause errors.