I didn't know w3tc would overwrite the htaccess unless you made changes to w3tc. Compare the htaccess file you have to rename after the 500 error with the htaccess file generated later.
And it seems it works even after the w3tc code is added but then your site randomly pops the error? Do you use cloudflare?