Plesk

How to enable custom error pages for a domain in Plesk

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

 

Enabling default error pages provided by Plesk

 

  • 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.

    Hosting 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.

    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/external_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;

 

Configuring custom HTML error pages

 

  1. 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).

  2. Create/upload your HTML error pages to the newly created directory.

  3. 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:

      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…

Exit mobile version