latest stable versions: v140725 (changelog)

Resolving Problems with File Downloads

There are several things you can try applying to your site to fix problems with downloads. Depending on your server configuration, one or all of these may be necessary. Please try each tweak in the order they are listed, testing your download after applying each change.

Disable GZIP Compression

If you're running s2Member with mod_deflate for Apache (common on many hosts, including BlueHost), you'll want to add this section to the top of your WordPress .htaccess file, so that your installation of Apache will know when it should NOT use GZIP compression. This .htaccess file should be located in the same root directory as your WordPress files.

# BEGIN s2Member GZIP exclusions
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{QUERY_STRING} (?:^|\?|&)s2member_file_download\=.+
	RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions
As of v120213, s2Member will automatically attempt to add this code to the .htaccess file at the web root.

This disables GZIP compression when s2Member attempts to deliver files. GZIP compression MUST be disabled during s2Member's attempt to deliver a file via PHP because files that s2Member delivers via PHP, are already compressed. Thus, re-compressing files delivered by a script will corrupt them in your browser.

Note that some media playback devices will choke on this as well. It's never a bad idea to place this in your .htaccess file, regardless of server configuration.

View more information about GZIP compression and s2Member

Ensure the /s2member-files/ .htaccess file is present

You should also have an .htaccess file in your /s2member-files/ directory. If you don't please re-install s2Member and that will create the proper .htaccess file. Either that, or add this to /wp-content/plugins/s2member-files/.htaccess:
Options +FollowSymLinks -MultiViews -Indexes

<IfModule mod_env.c>
   SetEnv no-gzip 1
</IfModule>

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /

   RewriteCond %{ENV:s2member_file_ms_scan} !^complete$
   RewriteCond %{THE_REQUEST} ^(?:GET|HEAD)(?:[\ ]+)(?:/)([_0-9a-zA-Z\-]+/)(?:wp-content/)
   RewriteRule ^(.*)$ - [E=s2member_file_ms_scan:complete,E=s2_blog:%1]

   RewriteCond %{ENV:s2member_file_download_scan} !^complete$
   RewriteRule ^(.*)$ - [E=s2member_file_download_scan:complete,E=s2member_file_download:$1]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-stream/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%2,E=s2member_file_stream:&s2member_file_stream=yes]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-stream-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_file_stream:&s2member_file_stream=%2]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-inline/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%2,E=s2member_file_inline:&s2member_file_inline=yes]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-inline-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_file_inline:&s2member_file_inline=%2]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-storage-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_file_storage:&s2member_file_storage=%2]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-remote/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%2,E=s2member_file_remote:&s2member_file_remote=yes]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-remote-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_file_remote:&s2member_file_remote=%2]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-ssl/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%2,E=s2member_file_ssl:&s2member_file_ssl=yes]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-ssl-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_file_ssl:&s2member_file_ssl=%2]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-file-download-key-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_file_download_key:&s2member_file_download_key=%2]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-skip-confirmation/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%2,E=s2member_skip_confirmation:&s2member_skip_confirmation=yes]

   RewriteCond %{ENV:s2member_file_download} ^(.*?)(?:s2member-skip-confirmation-(.+?)/)(.+)$
   RewriteRule ^(.*)$ - [N,E=s2member_file_download:%1%3,E=s2member_skip_confirmation:&s2member_skip_confirmation=%2]

   RewriteRule ^(.*)$ %{ENV:s2_blog}?s2member_file_download=%{ENV:s2member_file_download}%{ENV:s2member_file_stream}%{ENV:s2member_file_inline}%{ENV:s2member_file_storage}%{ENV:s2member_file_remote}%{ENV:s2member_file_ssl}%{ENV:s2member_file_download_key}%{ENV:s2member_skip_confirmation} [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
   deny from all
</IfModule>

Disable chunked file delivery

If it doesn't already exist, create this directory and file: /wp-content/mu-plugins/s2-hacks.php

Add the following line to s2-hacks.php:

<?php add_filter("ws_plugin__s2member_chunk_file_downloads", "__return_false"); ?>
The mu-plugins directory holds Must Use Plugins. These plugins are activated and run automatically with WordPress and do not require manual activation.

Disable both chunked & flushed file delivery

If it doesn't already exist, create this directory and file: /wp-content/mu-plugins/s2-hacks.php

Add the following line to s2-hacks.php:

<?php
add_filter("ws_plugin__s2member_chunk_file_downloads", "__return_false");
add_filter("ws_plugin__s2member_flush_file_downloads", "__return_false");
?>
The mu-plugins directory holds Must Use Plugins. These plugins are activated and run automatically with WordPress and do not require manual activation.

About the Author

Raam DevRaam is an explorer who seeks the adventure and wisdom of experience. He shares knowledge and ideas with great respect for individual potential and holds high regard for the legacy of humanity. Raam travels the world as a nomad and lives with what fits on his back. You may catch him crafting words in a cafe, hiking barefoot in a forest, or lost deep in thought wondering what it all means.View all posts by Raam Dev →

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.