cPanel/WHM custom 403 page for all accounts?

system-error

Member
Dec 16, 2014
21
1
3
cPanel Access Level
Root Administrator
Thanks for your help. I think I wasn't clerk exactly on the issue. The image resides here:

/usr/local/apache/customerror/images


So how should I link to the image from the shtml? I currently use src="/images/logo.png" but that is not working. I don't think I can link to
/usr/local/apache/customerror/images as a hardcoded link, right?
 

system-error

Member
Dec 16, 2014
21
1
3
cPanel Access Level
Root Administrator
So here is the code I'm using in the 404.html:

`<img src="/usr/local/apache/customerror/cloud.png">`

That does not display either... so part of the thread here says ot use customerror/images/ and that also doesn't work to display the image. Permissions are all fine and I even changed them around to test different 644, 755, 777, etc.

Am I missing something small about how to display the images (and css)?
 

system-error

Member
Dec 16, 2014
21
1
3
cPanel Access Level
Root Administrator
Hi, sorry to bump, but any idea how to utilize images within the error pages? If I add the images to a user account, that iuser account may not deliver the image because it has a high load or has an error, so is there a way to include images without relying on the user accounts?
 

TCB13

Well-Known Member
Jul 25, 2014
62
1
8
cPanel Access Level
Root Administrator
I tried this and I got:

Forbidden
You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Looks like there's some strange permission problem... Any tips?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,883
2,256
463
Looks like there's some strange permission problem... Any tips?
Could you let us know the specific steps you took before seeing this message in your browser? Note that /usr/local/apache/logs/error_log will have more details on the specific error message.

Thank you.
 

TCB13

Well-Known Member
Jul 25, 2014
62
1
8
cPanel Access Level
Root Administrator
Could you let us know the specific steps you took before seeing this message in your browser? Note that /usr/local/apache/logs/error_log will have more details on the specific error message.

Thank you.
So I edited /usr/local/apache/conf/includes/errordocument.conf like this:

Code:
ErrorDocument 403 /usr/local/apache/htdocs/error/403.html
(also tried just /403.html)

And after trying a page that would result on a 403, I get the error above. This is what I get under /usr/local/apache/logs/error_log:

[Sat May 07 14:22:03.301844 2016] [autoindex:error] [pid 123631] [client 89.114.154.60:61684] AH01276: Cannot serve directory /home/tadbento/public_html_demo/: No matching DirectoryIndex (index.html.var,index.htm,index.html,index.shtml,index.xhtml,index.wml,index.perl,index.pl,index.plx,index.ppl,index.cgi,index.jsp,index.js,index.jp,index.php4,index.php3,index.php,index.phtml,default.htm,default.html,home.htm,index.php5,Default.html,Default.htm,home.html) found, and server-generated directory index forbidden by Options directive
There's nothing there about the "Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request." message.

Thanks.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,883
2,256
463
And after trying a page that would result on a 403, I get the error above. This is what I get under /usr/local/apache/logs/error_log:
Could you try reproducing the issue with a test file in another directory, that's not part of an existing script, in order to narrow down the issue?

Thank you.
 

TCB13

Well-Known Member
Jul 25, 2014
62
1
8
cPanel Access Level
Root Administrator
Could you try reproducing the issue with a test file in another directory, that's not part of an existing script, in order to narrow down the issue?

Thank you.
What do you mean by "in another directory, that's not part of an existing script"?

/home/tadbento/public_html_demo/ is the directory for a subdomain and I don't have any files there. Since directory listing is disable it gives a 403.

Can you please explain what you want me to do? Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,883
2,256
463
Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome.

Thank you.
 

ItsMattSon

Well-Known Member
Sep 5, 2016
182
38
153
Perth
cPanel Access Level
Root Administrator
Hello :)

This can be achieved by creating an alias for "/errorfolder" in the /usr/local/apache/conf/httpd.conf file via the following steps:

1) Create a directory in /usr/local/apache to store your custom error messages. In this case, I have named the directory "customerror":

Code:
mkdir /usr/local/apache/customerror
2) Ensure your custom error pages have been added to this directory (400.shtml, 404.shtml, etc).

3) In Web Host Manager, browse to:

"WHM Main >> Service Configuration >> Apache Configuration >> Include Editor"

4) Select "All Versions" under "Pre Virtual Host Include".

5) Add the following to the text box:

Code:
Alias /errorfolder /usr/local/apache/customerror/
ErrorDocument 400 /errorfolder/400.shtml
ErrorDocument 401 /errorfolder/401.shtml
ErrorDocument 403 /errorfolder/403.shtml
ErrorDocument 404 /errorfolder/404.shtml
ErrorDocument 500 /errorfolder/500.shtml
6) Click "Update", and then click "Restart Apache".

Your custom error pages will now be used by default.

Thank you :)
Fantastic! Worked a charm 5 years on :) (if anyone is wondering if this solution is still applicable!)
 
  • Like
Reactions: cPanelMichael