Home > Blockchain >  How to serve a file with "Content-Encoding: gzip" header?
How to serve a file with "Content-Encoding: gzip" header?

Time:02-18

I have a game that I want run on my apache server.

When I try to view a game activity instance I redirect to the index.html file of the uploaded game.

Here is the code in view.php:

    $fp = get_file_packer('application/zip');
    $dest = $CFG->dirroot.'/mod/game/games/'.$file->get_filename().'_extracted';
    // Extract the stored_file instance into this destination.
    $files = $fp->extract_to_pathname($file, $dest);

    $fullurl = moodle_url::make_file_url('/mod/game/games/',$file->get_filename().'_extracted/index.html');
    redirect($fullurl);

Here is the .htaccess file for the unity web gl build:

IfModule mod_mime.c

RemoveType .gz
AddEncoding gzip .gz
AddType application/octet-stream .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

AddType applicationwasm .wasm

AddEncoding gzip .unityweb


IfModule

After redirecting the game won't load at all and there is one error in the console which is:

'Failed to load resource: the server responded with a status of 500 (Internal Server Error)'

CodePudding user response:

I noticed that I didn't have decompression fallback enabled in my publishing settings on my unity project, that resolved my issue.

  • Related