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 127.0.0.1...
* connected
* Connected to mage.dev (127.0.0.1) 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
Best Answer
Downloadable products are made for this. You can choose between an uploaded file or an URL for each downloadable item of the product:
Update: I was wrong
Magento proxies a download to the given URL instead of redirecting the customer, so some customization is necessary. I would still go with the downloadable product and add a new download type besides "File" and "URL", let's call it "Redirect"
Define new link type
Edit the form HTML in
app/design/adminhtml/default/default/template/downloadable/product/edit/downloadable/links.phtml
(copy the file to a custom admin theme and modify it). Create a new option for thedownloadable[link][{{id}}][type]
input called "redirect" (below "file" and "url"). There might be a more elegant way to change the template without this override, using JavaScript instead.Handle new link type
Create a new controller for the "downloadable" route, using
before="Mage_Downloadable"
to override Mage_Downloadable_DownloadController::linkAction(). I would extend the original controller and just override the_processDownload($resource, $resourceType)
method with something like this: