Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
Dear All,

After installing mod_h2 my websites work fine, even all the 301 redirects placed in .htaccess works
My issue is 404 pages

In my .htacccess I have custom error handling for 404 pages but instead the oldie custom error page apache default comes up.
"Not Found
The requested URL /en/dawd was not found on this server."

My .htaccess line is: (inside website folder root)
ErrorDocument 404 /404.php

Did work for years should work, now also.

My troublshoot was this:
404 in .htaccess with full url (DID NOT WORK)
custom 404 with cpanel (DID WORK, placed no new rules in .htaccess, but this is not what I want)
empty .htacces and leave one line only "ErrorDocument 404 /404.php" (DID NOT WORK)

What I assume is, it might be an error document setting in either httpd.conf or an included other conf file might be one included for h2 ??

I did not check my httpd.conf file as touching those without any instructions is what I avoid mostly.

Please let me know how to edit my httpd.conf if that is the problem ?
Or just let me know what could be the possible cause of the error

All best
Z
 

Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
Dear All,

Please let me know how to edit my httpd.conf if that is the problem ?
Or just let me know what could be the possible cause of the error

All best
Z
I did some troubleshoot, now please let me know if id did right?

I have opened /usr/local/apache/conf/htppd.conf
I found this line: Include "/etc/apache2/conf.d/includes/errordocument.conf"

After opening the included error documents, I found this for 404 pages
# 404 - Not Found
<If "-f '%{DOCUMENT_ROOT}/404.shtml'">
ErrorDocument 404 /404.shtml
</If>
#<Else>
# ErrorDocument 404 default
#</Else>

Here as you can see If shtml file saved it gives that one as 404. I guess this happens if you give a custom 404 in Cpanel. The problematic line here is the else statement which would give 404 before my .htaccess kicks in.

I just commented out that else statement and left everything untouched.
My custom 404 pages with .htaccess all works now.

(For settings to be live an apache restart is needed)

Is this a proper solution ? Was this error handling change by h2 or It did happen by any new feature of cpanel that I missed? Sorry I might missed this error for long, I just now realised after mod_http2 was put in place.

All best
Z
 
Last edited:

RickKukiela

Member
Jan 17, 2017
16
1
3
Chicago
cPanel Access Level
Root Administrator
So the other day our apache restarted and all of the sudden every single custom ErrorDocument set up in a .htaccess file stopped working. It turns out that on july 7th, a new file was added to my /etc/apache2/bin/ folder called 'generate-errordoc-conf' which is a script file that generated a file at /etc/apache2/conf.d/includes/errordocument.conf' This sets the errodocument directives globally for the whole server and its presence cause the .haccess errordocument directives to be completely ignored unless the error documents are named "/DOCROOT/<ERROR_CODE>.shtml" and unfortunately for me none of my site's custom error documents were a .shtml file type.

(Honestly who uses SHTML anymore? What is this 1998?)

I had to `mv errordocument.conf` errordocument.old` and restart apache to fix this problem. I'm worried that this script file is going to run again and recreate this config file I do not want.

I'm afraid if I delete the script out of bin, an update will just re-create it.

Is there a setting I can just disable this? I dont want updates messing with my configuration and I'm kind of pissed that I did this time around. It caused me a bunch of wasted time trying to figure out what the hell happened and how to fix it.

In the future please do not introduce changes that are going to just break previously working configs without any type of confirmation by us.

Thanks.
 
  • Like
Reactions: RadWebHosting

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Hello,

Internal case EA-6533 is open to address an issue where /etc/apache2/conf.d/includes/errordocument.conf takes precedence over individual ErrorDocument entries in .htaccess files and thus makes any ErrorDocument directive in htaccess irrelevant. I'll monitor the status of this case and update this thread with more information as it becomes available.

Edit - [Temporary workaround removed]

To update, this was fixed in yesterday's EasyApache 4 update:

EA-6536: undo EA-6159 since it interferes with some redirects

After completing the "yum update" command on your system, please use the following commands to restore the errordocument.conf file to the default state if you used the temporary workaround initially provided on this post:

Code:
mv /etc/apache2/conf.d/includes/errordocument.conf /etc/apache2/conf.d/includes/errordocument.conf.backup1
yum reinstall ea-apache24-config-runtime
Thank you.
 
Last edited:

Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
In the meantime, a temporary workaround is to remove the "Else" statements from /etc/apache2/conf.d/includes/errordocument.conf using the following commands:
Hello,

Sorry I am not that deep into server config this is why I picked cpanel rather than doing commands on my own.
I am saying this as I did not really understand your commands. (I guess it just removes else statement but not sure in that)

What I want to ask:
I also figured out that the problem is the else statement and commented it out.
Is this a proper solution or by time some refresh might recreate the file and we are back where we started ?

Or just relax and possible next generation of file is after the fix of this issue.

Bye
Z

P.S. I commented out else for 404 and my one works now ! Also wasted a lot of time, would be better to watch GOT instead :)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
I also figured out that the problem is the else statement and commented it out. Is this a proper solution or by time some refresh might recreate the file and we are back where we started ?
Hello,

This is the temporary workaround until a resolution associated with internal case EA-6533 is published. cPanel updates will not modify the errordocument.conf file in the meantime. I'll monitor the internal case and update this thread with more information about the resolution as it becomes available.

Thank you.
 
  • Like
Reactions: Zoltan Szabo

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Hello,

To update, this was fixed in yesterday's EasyApache 4 update:

EA-6536: undo EA-6159 since it interferes with some redirects

After completing the "yum update" command on your system, please use the following commands to restore the errordocument.conf file to the default state if you used the workaround provided in my earlier post to this thread:

Code:
mv /etc/apache2/conf.d/includes/errordocument.conf /etc/apache2/conf.d/includes/errordocument.conf.backup1
yum reinstall ea-apache24-config-runtime
Thank you.