woostar

Member
Mar 13, 2011
10
0
51
.htaccess files keep getting created.

All my websites stop working and start downloading php files to users browsers.

I need it to stop.

Please please please can someone tell me how to stop this code getting added to .htaccess?
I don't use htaccess's I use virtualhost conf.d/includes.
Apache config:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,272
313
Houston
As far as I understand it there is no supported method to keep this from being created. It's done automatically by cPanel. What are you adding in the VirtualHost include?
 

Luana Premoli

Well-Known Member
Oct 3, 2016
68
7
8
São Paulo/Brazil
cPanel Access Level
Root Administrator
Hi,

We always set the PHP version directly through .htaccess and it always worked correctly. Now it is also changing automatically.


I noticed that the cPanel update log (Aug 22 01:22 /var/cpanel/updatelogs/last) has an approximate file change time (Aug 22 01:25):


Code:
[[email protected] /home/sinttelg/public_html]# ll .htaccess*
-rw-r--r-- 1 sinttelg sinttelg 4236 Aug 22 09:50 .htaccess
-rw-r--r-- 1 sinttelg sinttelg 4214 Aug 14 01:22 .htaccess.phphandler.1565787528
-rw-r--r-- 1 sinttelg sinttelg 4219 Aug 19 22:18 .htaccess.phphandler.1566305380
-rw-r--r-- 1 sinttelg sinttelg 4219 Aug 22 01:25 .htaccess.phphandler.1566478247
[[email protected] /home/sinttelg/public_html]#


Code:
[[email protected] /home/sinttelg/public_html]# ll /var/cpanel/updatelogs/last
lrwxrwxrwx 1 root root 44 Aug 22 01:22 /var/cpanel/updatelogs/last -> /var/cpanel/updatelogs/update.1566447721.log
[[email protected] /home/sinttelg/public_html]#
[[email protected] /home/sinttelg/public_html]#
Wanted to know why this happened?


Code:
[[email protected] ~]# grep '' /etc/redhat-release /usr/local/cpanel/version
/etc/redhat-release:CentOS release 6.10 (Final)
/usr/local/cpanel/version:11.78.0.36
[[email protected] ~]#
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,272
313
Houston
As of v78 we started auto-updating the .htaccess with the PHP configuration currently set in the Multi-PHP Manager. The text in the .htaccess also clearly indicates that the speciifc portion is auto-generated and should not be modified manually. For example:

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

ripefruit

Registered
Oct 8, 2009
3
0
51
We've been experiencing this same issue for 6 months.
In our case, cpanel changes the package in htaccess from ea-php52 to ea-php71 causing the site to crash (500 server error)
We change the handler back to 52 and the website works again.
Now, the strange part is we have two identical web sites on the same server, same PHP, save everything except for the domain. The second site is never updated.
Any assistance would greatly be appreciated.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,272
313
Houston
You cannot set the PHP version through the .htaccess, it must be set through the MultiPHP Editor, the .htaccess will be updated to whatever is selected in the cPanel account's MultiPHP Interface.
 
Oct 4, 2021
5
0
1
United States
cPanel Access Level
Root Administrator
any solutions getting same issue on our servers

# To remove index.php from URL

RewriteEngine On
RewriteBase /

Options All -Indexes

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#RewriteCond %{HTTP_HOST} !^us01\. [NC]
#RewriteRule .* https://us01.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#extracted

RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

#RewriteRule ^/assets/images/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/logo\.png$ /images.php?file=$1.png [NC,L]

# 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 php5_module>
#php_flag asp_tags Off
#php_flag display_errors On
#php_value max_execution_time 30
#php_value max_input_time 60
#php_value max_input_vars 1000
#php_value memory_limit 128M
#php_value post_max_size 8M
#php_value session.gc_maxlifetime 1440
#php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
#php_value upload_max_filesize 2M
#php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit

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

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,027
313
cPanel Access Level
Root Administrator
The only part of the file cPanel will edit is the section at the bottom that looks like this:

Code:
# 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
Everything above that line is not managed by cPanel, so if that is where you are seeing the changes made it is something else editing that file.