Question
How to set up custom error pages for a domain in Plesk?
Answer
Note: In some cases, custom error pages may not work properly due to customized domain configuration (in .htaccess file, additional Apache/nginx directives on Linux and web.config file on Windows Server).
For Linux
-
If Proxy Mode is enabled at Domains > example.com > Apache & nginx Settings, then: go to Domains > example.com > Hosting Settings and enable the Custom error documents setting:
Note: If PHP is run as PHP-FPM application served by Apache, add "ProxyErrorOverride on" to the additional HTTP/HTTPS directives at Domains > example.com > Apache & nginx Settings.
-
If Proxy Mode is disabled at Domains > example.com > Apache & nginx Settings, add the following content to Additional nginx directives field:
Notes: The Additional nginx directives field is available to Plesk administrator only. If you are a domain owner, please contact your service provider for assistance with configuration of error pages.
To apply these settings for all new domains created under a particular service plan, go to Service Plans > Example Plan > Web Server tab and add the below lines to the Additional nginx directives field.CONFIG_TEXT: fastcgi_intercept_errors on;
location ^~ /error_docs/ { root /var/www/vhosts/example.com/; }
error_page 400 /error_docs/bad_request.html;
error_page 401 /error_docs/unauthorized.html;
error_page 403 /error_docs/forbidden.html;
error_page 404 /error_docs/not_found.html;
error_page 405 /error_docs/method_not_allowed.html;
error_page 406 /error_docs/not_acceptable.html;
error_page 407 /error_docs/proxy_authentication_required.html;
error_page 412 /error_docs/precondition_failed.html;
error_page 414 /error_docs/request-uri_too_long.html;
error_page 415 /error_docs/unsupported_media_type.html;
error_page 500 /error_docs/internal_server_error.html;
error_page 501 /error_docs/not_implemented.html;
error_page 502 /error_docs/bad_gateway.html;
error_page 503 /error_docs/maintenance.html;
-
In Plesk, go to Domains > example.com > File Manager > click Home directory > then click
and create a new directory for your custom error pages (For example, custom_error_pages).
-
Create/upload your HTML error pages to the newly created directory.
-
Configure error pages:
Note: Add only those error code lines, for which custom error pages exist in your directory.
-
If Proxy Mode is enabled at Domains > example.com > Apache & nginx Settings:
Go to Domains > example.com > Apache & nginx Settings and add the following content to the Additional directives for HTTP and Additional directives for HTTPS. Replace custom_error_pages in each line, if your directory has a different name:
CONFIG_TEXT: Alias /custom_error_pages /var/www/vhosts/example.com/custom_error_pages
ErrorDocument 400 /custom_error_pages/bad_request.html
ErrorDocument 401 /custom_error_pages/unauthorized.html
ErrorDocument 403 /custom_error_pages/forbidden.html
ErrorDocument 404 /custom_error_pages/not_found.html
ErrorDocument 405 /custom_error_pages/method_not_allowed.html
ErrorDocument 406 /custom_error_pages/not_acceptable.html
ErrorDocument 407 /custom_error_pages/proxy_authentication_required.html
ErrorDocument 412 /custom_error_pages/precondition_failed.html
ErrorDocument 414 /custom_error_pages/request-uri_too_long.html
ErrorDocument 415 /custom_error_pages/unsupported_media_type.html
ErrorDocument 500 /custom_error_pages/internal_server_error.html
ErrorDocument 501 /custom_error_pages/not_implemented.html
ErrorDocument 502 /custom_error_pages/bad_gateway.html
ErrorDocument 503 /custom_error_pages/maintenance.html -
If Proxy Mode is disabled at Domains > example.com > Apache & nginx Settings:
Add the following content to the Additional nginx directives field:
CONFIG_TEXT: fastcgi_intercept_errors on;
location ^~ /custom_error_pages/ { root /var/www/vhosts/example.com/; }
error_page 400 /custom_error_pages/bad_request.html;
error_page 401 /custom_error_pages/unauthorized.html;
error_page 403 /custom_error_pages/forbidden.html;
error_page 404 /custom_error_pages/not_found.html;
error_page 405 /custom_error_pages/method_not_allowed.html;
error_page 406 /custom_error_pages/not_acceptable.html;
error_page 407 /custom_error_pages/proxy_authentication_required.html;
error_page 412 /custom_error_pages/precondition_failed.html;
error_page 414 /custom_error_pages/request-uri_too_long.html;
error_page 415 /custom_error_pages/unsupported_media_type.html;
error_page 500 /custom_error_pages/internal_server_error.html;
error_page 501 /custom_error_pages/not_implemented.html;
error_page 502 /custom_error_pages/bad_gateway.html;
error_page 503 /custom_error_pages/maintenance.html;
-
-
In Plesk, go to Domains > example.com > File Manager > click
and create a new directory for your custom error pages (For example, custom_error_pages) inside the httpdocs directory.
Note: If the domain has a custom document root (e.g. httpdocs/website) at Domains > example.com > Hosting Settings, create the directory for custom error pages there (httpdocs/website/custom_error_pages).
-
Create/upload your PHP error pages to the newly created directory.
-
Configure error pages:
Note: Add only those error code lines, for which custom error pages exist in your directory.
-
If Proxy Mode is enabled at Domains > example.com > Apache & nginx Settings:
Go to Domains > example.com > Apache & nginx Settings and add the following content to the Additional directives for HTTP and Additional directives for HTTPS. Replace custom_error_pages in each line, if your directory has a different name:
CONFIG_TEXT: ProxyErrorOverride on
<Location /custom_error_pages/>
ProxyErrorOverride off
</Location>
ErrorDocument 400 /custom_error_pages/bad_request.php
ErrorDocument 401 /custom_error_pages/unauthorized.php
ErrorDocument 403 /custom_error_pages/forbidden.php
ErrorDocument 404 /custom_error_pages/not_found.php
ErrorDocument 405 /custom_error_pages/method_not_allowed.php
ErrorDocument 406 /custom_error_pages/not_acceptable.php
ErrorDocument 407 /custom_error_pages/proxy_authentication_required.php
ErrorDocument 412 /custom_error_pages/precondition_failed.php
ErrorDocument 414 /custom_error_pages/request-uri_too_long.php
ErrorDocument 415 /custom_error_pages/unsupported_media_type.php
ErrorDocument 500 /custom_error_pages/internal_server_error.php
ErrorDocument 501 /custom_error_pages/not_implemented.php
ErrorDocument 502 /custom_error_pages/bad_gateway.php
ErrorDocument 503 /custom_error_pages/maintenance.php-
-
Additional step if PHP-FPM by nginx is being used:
Go to Domains > example.com > Apache & nginx Settings and add the following content to the Additional nginx directives. Replace custom_error_pages in each line, if your directory has a different name:
CONFIG_TEXT: fastcgi_intercept_errors on;
error_page 400 /custom_error_pages/bad_request.php
error_page 401 /custom_error_pages/unauthorized.php
error_page 403 /custom_error_pages/forbidden.php
error_page 404 /custom_error_pages/not_found.php
error_page 405 /custom_error_pages/method_not_allowed.php
error_page 406 /custom_error_pages/not_acceptable.php
error_page 407 /custom_error_pages/proxy_authentication_required.php
error_page 412 /custom_error_pages/precondition_failed.php
error_page 414 /custom_error_pages/request-uri_too_long.php
error_page 415 /custom_error_pages/unsupported_media_type.php
error_page 500 /custom_error_pages/internal_server_error.php
error_page 501 /custom_error_pages/not_implemented.php
error_page 502 /custom_error_pages/bad_gateway.php
error_page 503 /custom_error_pages/maintenance.php
-
-
-
If Proxy Mode is disabled at Domains > example.com > Apache & nginx Settings:
Add the following content to Additional nginx directives field:
CONFIG_TEXT: fastcgi_intercept_errors on;
error_page 400 /custom_error_pages/bad_request.php;
error_page 401 /custom_error_pages/unauthorized.php;
error_page 403 /custom_error_pages/forbidden.php;
error_page 404 /custom_error_pages/not_found.php;
error_page 405 /custom_error_pages/method_not_allowed.php;
error_page 406 /custom_error_pages/not_acceptable.php;
error_page 407 /custom_error_pages/proxy_authentication_required.php;
error_page 412 /custom_error_pages/precondition_failed.php;
error_page 414 /custom_error_pages/request-uri_too_long.php;
error_page 415 /custom_error_pages/unsupported_media_type.php;
error_page 500 /custom_error_pages/internal_server_error.php;
error_page 501 /custom_error_pages/not_implemented.php;
error_page 502 /custom_error_pages/bad_gateway.php;
error_page 503 /custom_error_pages/maintenance.php;
-
Above instructions do not work anymore if WordPress is installed under domain because of https://support.plesk.com/hc/en-us/articles/360020690179.
For Windows Server
-
In Plesk, go to Domains > example.com > Hosting Settings and make sure that the Custom error documents setting is enabled.
-
Go to Domains > example.com > Virtual Directories > Error Documents tab > click on a required error page and make sure that it has a File type.
-
Go to File Manager > error_docs > click on a required custom document and modify it according to your needs. Here is a list of the error pages names:
PLESK_INFO: 400 Bad File Request - bad_request.html
401 Unauthorized - unauthorized.html
403 Forbidden/Access denied - forbidden.html
404 Not Found - not_found.html
405 Method Not Allowed - method_not_allowed.html
406 Not Acceptable - not_acceptable.html
407 Proxy Authentication Required - proxy_authentication_required.html
412 Precondition Failed - precondition_failed.html
414 Request-URI Too Long - request-uri_too_long.html
415 Unsupported Media Type - unsupported_media_type.html
500 Internal Server Error - internal_server_error.html
501 Not Implemented - not_implemented.html
502 Bad Gateway - bad_gateway.html
503 Service Temporarily Unavailable - maintenance.html
-
In Plesk, go to Domains > example.com > Hosting Settings and make sure that the Custom error documents setting is enabled.
-
Go to File Manager > httpdocs and create your custom error pages.
-
Once created, go to Domains > example.com > Virtual Directories > Error Documents tab and click on a required error page.
-
Change its type to URL and specify the Location of the custom error page. For example, if the file not_found.php is located in httpdocs, the location will be http://example.com/not_found.php (or https://example.com/not_found.php if the website is using a secure connection). Click OK to apply the changes.
-
Now open a non-existent page in a browser to check newly configured custom error page.
Note for Plesk administrators: If a non-existent page on this website is opened directly on a Plesk server, a default IIS page will appear. This is behavior by default.
Comments
6 comments
It'd be nice if these nginx custom error settings were automatic when the custom error messages box was checked in plesk. We've determined the nginx 502 error page is the one customers see when plesk changes are made to domains requiring rebuilding apache/nginx config and restarting... It would be nice if we could easily globally set a prettier custom error page as a default server wide.
Hello @Tony,
Thank you for sharing the idea.
I have created a feature-suggestion: https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/36231586-add-server-wide-custom-error-pages-configuration-v?
If it becomes popular, it will be implemented. Feel free to vote for it.
I followed the directions for the custom php error pages. It's showing the page, but without the php includes. Why?
Hi Kathy Sechrist could you show us an example of how it looks and what is missing?
I followed the steps but it's not working with me, still seeing the default chrome page for 500 errors, also helpful to note that I don't have any custom .htaccess files on the root directory, what else might be causing the issue? could you please assist? thank you.
For NODEJS apps and if using PhusionPassenger, you need to add in "Go to Domains > example.com > Apache & nginx Settings and add the following content to the Additional directives for HTTP and Additional directives for HTTPS"
Please sign in to leave a comment.