script to remove cPanel-generated handler from htaccess

whplus

Well-Known Member
Dec 8, 2007
82
3
58
Behind your business
EA4 adding this stuff to many htaccess files. Is there any script to remove this from each htaccess at once?
Code:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
    AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
 

dalem

Well-Known Member
PartnerNOC
Oct 24, 2003
2,983
159
368
SLC
cPanel Access Level
DataCenter Provider
That sets your php version you do not want to remove it

I suppose you could build a bash script to remove them all and php would revert to inherent but I do not see the reason why you would want to.
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
Hello @whplus,

The entries in the .htaccess file make it possible for an individual cPanel user to change the version of PHP assigned to the account as part of the cPanel >> MultiPHP Manager feature and to ensure changes made through cPanel >> MultiPHP INI Editor are preserved if the handler changes in the future. You can read more about this at:

MultiPHP INI Editor for cPanel - Version 74 Documentation - cPanel Documentation

While it's technically possible to move the AddType entry from the .htaccess file to the individual virtual host, doing so is unsupported because other features such as PHP version detection via CLI rely on the entries in the .htaccess file.

I encourage you to vote for the following feature request if you'd like to see these .htaccess entries moved elsewhere:

Put PHP version choices in server configuration

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
I use phpselector and apache mod_lsapi, so those stuff in htaccess break php. it is downloading php pages instead of displaying them.
Hi @whplus,

Can you open a support ticket so we can take a closer look at your system to see why that's happening? You can post the ticket number here and we'll link this thread to it.

Thank you.
 

whplus

Well-Known Member
Dec 8, 2007
82
3
58
Behind your business
i guess it was coming from suphp/cPanelMultiPHP, but it's still there after switched to mod_lsapi/phpselector.
i already used bash script to add comment (#) in front of 'AddType application/x-httpd-ea-php56' of each .htaccess
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
Hello @whplus

Can you share the ticket number so I can take a look and update this thread with the outcome? While those .htaccess entries are populated, they should not result in a download prompt appearing when attempting to access a PHP file on systems using mod_lsapi.

Thank you.