All of the zip files downloadables from my site are being corrupted.

Looking for answers online I always find the same result: To edit htaccess because it is double compressing the files. I'm quite certain this is the problem as if I go to the link directly it works, and if I upload a zip file uncompressed, it works.

I have tried editing my htaccess to match the code below but it does not seem to work!?

• Do I need to place an htaccess file with that right in the /downloadable directory?

• Could I use an external link as a download, i.e through dropbox or something?

    # php_flag zlib.output_compression on # problems with downloadable content


# Insert filter on all content
### SetOutputFilter DEFLATE # problems with downloadable content
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
  • 1
    Are the sizes of the downloaded files ok? If you try to zip too much, you might get a out of memory error and only this error is in the zip, try to open it with an editor, if it is only a few kB big. May 8, 2013 at 7:46
  • I run into this issue as well. Any idea what's wrong on server setup? I tried to disable zlib with ini_set("zlib.output_compression", "Off"); but it didn't help :(.
    – pevik
    May 24, 2020 at 19:23
  • Also reported: github.com/magento/magento2/issues/21085
    – pevik
    May 24, 2020 at 19:46

2 Answers 2


If this is happening to direct downloads of zip files, it's definitely the rules in the .htaccess or apache config. You'll want to update this section of your .htaccess file:

# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

with this:

# Don't compress images or zip files
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|zip)$ no-gzip dont-vary

Then make sure that you DO NOT have the blanket SetOutputFilter DEFLATE rule set and are only using the AddOutputFilterByType rule to enable the compression. The latter one will turn it on based on mime-type, whereas the first enables it across the board on everything.

After you do this, the server should definitely NOT be double compressing the data when serving files resources where the URL ends in .zip by merit of the mime-type as well as the URI matching the pattern.

If this is happening only on downloads of zip files from purchased downloadable products, and you've done both of the things mentioned above, then you'll need to verify that the Content-Type: application/zip header is being sent with the download since Magento essentially proxies the content to the browser in a data stream and sets the mime-types itself.

The easiest way to check the headers is to use curl like this:

$ curl -sv http://mage.dev/1.7/downloadable/download/linkSample/link_id/1/ > /dev/null
* About to connect() to mage.dev port 80 (#0)
*   Trying
* connected
* Connected to mage.dev ( port 80 (#0)
> GET /1.7/downloadable/download/linkSample/link_id/1/ HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: mage.dev
> Accept: */*
< HTTP/1.1 200 OK
< Date: Wed, 08 May 2013 01:55:36 GMT
< Server: Apache/2.2.22 (Unix) PHP/5.3.14 mod_ssl/2.2.22 OpenSSL/0.9.8o
< X-Powered-By: PHP/5.3.14 ZendServer/5.0
< Set-Cookie: frontend=v8qacn7t586ckfljbibnm4ea82; expires=Wed, 08-May-2013 02:55:36 GMT; path=/1.7; domain=mage.dev; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: must-revalidate, post-check=0, pre-check=0
< Pragma: public
< Content-Length: 905467
< Content-Disposition: inline; filename=lame.zip
< Content-Type: application/zip
{ [data not shown]
* Connection #0 to host mage.dev left intact
* Closing connection #0
  • hi i have the same probelm with downloadproducts, since the download is processed in php you fix won't work, is it possible to disable gtzip for urls which start with downloadable/download/link/id/ ?
    – wutzebaer
    Aug 14, 2014 at 9:54

In my case that was due to a change in the (Dropbox) server response header: the add the Transfer-Encoding: chunked header and consequently removed the Content-Length header.

To solve that you should override the _processDownload method in app/code/core/Mage/Downloadable/controllers/DownloadController.php and change these lines:


protected function _processDownload($resource, $resourceType)

        // if ($fileSize = $helper->getFilesize()) {
        //     $this->getResponse()
        //         ->setHeader('Content-Length', $fileSize);
        // }

        ->setHeader('Transfer-Encoding', 'chunked');


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.