WHM .htaccess add .html and .htm to AdHandler

Operating System & Version
centos8
cPanel & WHM Version
v96.0.8

muneeb852

Member
May 25, 2021
17
2
3
Pakistan
cPanel Access Level
Root Administrator
Hello everyone,
When we make a new account cPanel creates this code inside .htaccess for php8 automatically. if we change to php7 it will replace it with similar code with php7.
Now, I wanted to process .html and .html file as php.
One way is to just add it after .phtml but that is automatically replaced after some time by cPanel or when changing to other version it will be replaced and .html will no more be processed by php.
What I want is to somehow add .html .htm to this configuration so whenever a new cPanel account is created it have .html and .html inside the configuration, even after the change it should be persisted.
Is there any place at WHM when I can replace what should be added to .htaccess file at creation of account or changing of php version via php manager ?

Apache config:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php80” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php80 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
 

muneeb852

Member
May 25, 2021
17
2
3
Pakistan
cPanel Access Level
Root Administrator
To overcome this problem, I am trying a bit hacky way here, need experts to to verify if i am doing something wrong here.

Apache config:
<IfModule mime_module>
    AddHandler application/x-httpd-ea-php73 .html .htm .shtml
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php80” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php80 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
As cPanel only change code that is inside # php -- tags, so i have placed a code for html types, so whenever .html or .htm page is served. it will be served via php7.3 but whenever .php is served it will be served via the chosen php version from PHP Manager.

Experts, Please tell me, Will everything be alright with this ?
I just want to serve .html with php and don't want cPanel to overwrite my .htaccess becasue it removes .html for handler list if i give it inside # php --
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,027
313
cPanel Access Level
Root Administrator
Hey there! Apache will handle multiple AddHandler lines, so that is fine. I would just caution that this will require a bit of extra maintenance as you'll want to make sure your custom value matches the PHP version set for the domain to avoid conflicts.