Hello,
As you mentioned that you owns a dedicated server and your .htaccess is compromised for all sites.
I am well aware to such issues and fixed it in my past. First, I suggest you to change all the passwords including root, cpanel and delete ftp if you have.
It seems that some shell has been placed which is required to found. I will install the security script on your server which will find most of the malicious signature files and clean or remove them as depend on the critical nature.
For .htacess current issue we need to make a bash script and run it to fix almost all the .htacess once for the complete server.
Please feel free to contact if you have any queries in this concern.
Looking forward to hear from you.
Best
Atul