How to customize a 400 error page?

rappie

Active Member
Oct 4, 2008
29
4
53
Amsterdam
Whenever a request is made to my server (to any of the domains) with a invalid charter in the header key an error 400 is rightfully returned. I like to change the content of this error page for a specific sub domain. And I seem unable to.

This might seem straightforward to achieve, but I have yet to accomplish this for my scenario. The obvious answer would be to create a custom 400 error page trough cPanel. A 400.shtml file does get created in the directory, but it doesn't seem to get used in my case. So setting an error page in .htaccess then? Nope, no luck either.



How to reproduce (note the ö charter in the http header key pair, which is invalid).

Code:
curl --request POST \
--url 'http://example.com' \
--header 'föö: bar' \
--data '' \
--include
Will return:

Code:
HTTP/1.1 400 Bad Request
Date: Thu, 12 Sep 2019 15:21:59 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
 

rappie

Active Member
Oct 4, 2008
29
4
53
Amsterdam
Hi @cPanelLauren, thank you, I know. However, unfortunately this doesn't work in the scenario described my previous post. The modified error page isn't used in this case. So the question remains; how do I change the error page for a specific (sub) domain for this scenario?
 

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
7,907
625
263
Houston
cPanel Access Level
DataCenter Provider
That should be the method to make this modification if it's not functioning as intended I'd assume a misconfiguration at some point.

You should be able to set this for the specific subdomain, from that interface.

If that's not working you might try adding the following into your .htaccess file for the domain:

Code:
ErrorDocument 400 /400.shtml
If it still doesn't function properly I'd suggest opening a ticket so it can be investigated further