Symptoms
- After a cPanel UPCP run triggered by an ea-* package upgrade, the
.htaccessfile of one or more cPanel accounts is wiped. -
All custom content (WordPress rewrite rules, redirects, security headers, caching directives) is removed. Only the cPanel-generated PHP handler block remains:
CONFIG_TEXT: # php -- BEGIN cPanel-generated handler, do not edit
# php -- END cPanel-generated handler, do not edit - The new inode on the
.htaccessfile confirms it was fully replaced, not edited in place. -
Only some accounts on the same server may be affected.
Cause
This is a cPanel bug with ID CPANEL-53617. During a package upgrade, the 009-phpconf.pl DNF hook reads an empty .htaccess If another process (such as a WordPress cron job or a caching or security plugin) has the file open for writing, it will overwrite it with only the generated handler block.
Resolution
- Log into the server via SSH as the root user.
-
Check whether a backup of the file exists:
# ls -lah /home/<user>/public_html/.htaccess*
-
Create a backup copy of the wiped file:
Note: Replace <user> with the cPanel account username.
# cp -a /home/<user>/public_html/.htaccess /home/<user>/public_html/.htaccess.wiped
-
If a
.htaccess.bakor dated backup file is present, restore it:Note: Replace <user> with the cPanel account username.
# cp /home/<user>/public_html/.htaccess.bak /home/<user>/public_html/.htaccess
If no server-side backup exists, restore the file from your external backup source (JetBackup, R1Soft, Acronis, etc.).
-
Verify the ownership and permissions of the restored file:
Note: Replace <user> with the cPanel account username.
# chown <user>:<user> /home/<user>/public_html/.htaccess && chmod 644 /home/<user>/public_html/.htaccess
As a workaround to prevent recurrence, set the immutable flag on the file:
-
Set the immutable flag:
Warning: The immutable flag blocks all writes to the file, including legitimate updates from cPanel, WordPress, and plugins.
Note: Replace <user> with the cPanel account username.
# chattr +i /home/<user>/public_html/.htaccess
-
To make any change to the file later, remove the flag first:
Note: Replace <user> with the cPanel account username.
# chattr -i /home/<user>/public_html/.htaccess
Comments
0 comments
Article is closed for comments.