cPanel Optimize Website fixing error “OptimizeWS::optimizews(,) failed: Modification of non-creatable array value attempted, subscript -1 at /usr/local/cpanel/Cpanel/OptimizeWS.pm line 104.”
If you are trying to enable Optimize Website from your Cpanel and you get error. Then you must follow this small steps to fix it.
1. Make sure that you have access to root access to your server, you should have a VPS or a dedicate server.
2. check your cpanel username than have this error and note it, for example we will use “MYCPANELUSER”
3. Access your server for example with putty and log in as root.
4. Replace MYCPANELUSER with your cpanel user from the flowing command:
mv /home/MYCPANELUSER/.htaccess /home/MYCPANELUSER/.htaccess.bak
and paste it to putty ssh and press enter.
5. Also from this command replace MYCPANELUSER with your user:
echo > /home/MYCPANELUSER/.htaccess; chown MYCPANELUSER.MYCPANELUSER /home/MYCPANELUSER/.htaccess
and after replacing paste it to putty and press enter.
6 Go no back to cPanel Optimize Website and use Compress all content, now all should be ok.
Issue was solve on a CentOS VPS server with CPanel