HML5 compressed files- SyntaxError: illegal character

I don’t know if the needed contents of .htaccess file can vary per hosting server (e.g. if Apache is configured differently, or different Apache versions), but looking at project files from one UE4 project that did use .htaccess with Apache, it seems to have the following in it:

AddType application/x-javascript .jsgz    
AddType application/octet-stream .datagz
AddType application/wasm .wasm
AddType application/wasm .wasmgz

RewriteEngine on 
# If client accepts compressed files 
RewriteCond %{HTTP:Accept-Encoding} gzip 
# and if compressed file exists 
RewriteCond %{REQUEST_FILENAME}gz -f 
# send .extgz instead of .ext 
RewriteRule ^(.+)\.(mem|js|data|symbols|wasm)$ $1.$2gz

AddEncoding gzip .jsgz 
AddEncoding gzip .datagz
AddEncoding gzip .memgz
AddEncoding gzip .symbolsgz
AddEncoding gzip .wasmgz

Though I have not tested or deployed this project in practice to verify it first hand.