Help Code Review – I need to write on .htaccess file from theme’s function.php

The code below has work for me in the past 🙂

function add_to_htaccess( $rules ) {

  $content = <<<EOD
  # Enable Vary: Accept-Encoding Start
  <IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
  Header append Vary: Accept-Encoding
  </FilesMatch>
  </IfModule>
  EOD;
 return $content . $rules;

}
add_filter('mod_rewrite_rules', 'add_to_htaccess');