How to remove extra PHP section from .htaccess

chcw

Member
Jun 30, 2023
15
0
1
Hong Kong
cPanel Access Level
Root Administrator
Hi,

In my .htaccess file, there is already a section of PHP, as below:

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (PHP Home - EasyApache 4 - cPanel Documentation)
<IfModule php7_module>
php_flag display_errors Off
php_value max_execution_time 90
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 512M
php_value post_max_size 4M
php_value session.gc_maxlifetime 2880
php_value upload_max_filesize 4M
php_flag zlib.output_compression Off
php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
</IfModule>
<IfModule lsapi_module>
php_flag display_errors Off
php_value max_execution_time 90
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 512M
php_value post_max_size 4M
php_value session.gc_maxlifetime 2880
php_value upload_max_filesize 4M
php_flag zlib.output_compression Off
php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
</IfModule>
# END cPanel-generated php ini directives, do not edit

Then when I try to change the PHP to 8.1 in WHM > MultiPHP Manager, I will get "Access Error". Then I go to cPanel and make the change, it works. But it do not remove the above section, instead, it appending a new section below the above one:

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

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (PHP Home - EasyApache 4 - cPanel Documentation)
<IfModule php7_module>
php_flag display_errors Off
php_value max_execution_time 90
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 512M
php_value post_max_size 4M
php_value session.gc_maxlifetime 2880
php_value upload_max_filesize 4M
php_flag zlib.output_compression Off
php_value session.save_path "/var/cpanel/php/sessions/ea-php74"
php_flag log_errors On
php_value error_reporting E_ALL
php_value error_log "/home/xxxx/public_html/customer/error_log"
</IfModule>
<IfModule lsapi_module>
php_flag display_errors Off
php_value max_execution_time 90
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 512M
php_value post_max_size 4M
php_value session.gc_maxlifetime 2880
php_value upload_max_filesize 4M
php_flag zlib.output_compression Off
php_value session.save_path "/var/cpanel/php/sessions/ea-php74"
php_flag log_errors On
php_value error_reporting E_ALL
php_value error_log "/home/xxxx/public_html/customer/error_log"
</IfModule>
# END cPanel-generated php ini directives, do not edit

I try to remove the first section for PHP 7.3 manually. But after some time, I find it back to .htaccess. So, how to eliminate this section?
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
Hey there! It doesn't look like there are any custom entries in that .htaccess file, so could you try this to empty it?

cp /home/xxxx/public_html/.htaccess{,.bak-`date +%Y%m%d`}
echo "" > /home/xxxx/public_html/.htaccess

That first command will create a backup of the file, and the second will empty it out completely. Then you can try the PHP adjustments again and see what gets put in the file.