Access Control Lists (ACLs) in Linux are your friend – setfacl and getfacl

Shrare the real case using ACLs to get the solution of special permissions to modify .htaccess file with a script run by other user than www-data.