Support » Fixing WordPress » How to alter .htaccess to fix .epub downloads

  • I wonder if anyone can help me fix up WordPress to allow download of .epub files for ereaders. It involves a bit of .htaccess knowledge: mine is rudimentary to say the least.

    I’m having a problem with the issue of WordPress serving unknown files with the content-type of “Content-Type text/plain” in the HTTP header.

    I have followed the instructions on the helpful adding-ebook-epub-and-mobi-downloads-to-wordpress/.

    I’ve changed .htaccess to include, as suggested:
    AddType application/epub+zip .epub
    AddType application/x-mobipocket-ebook .mobi

    Nowt happens…

    What this means is that:
    1) Mac users get binary code gobbledygook when attempting to download a .epub file
    2) Internet Explorer users get a .zip file instead of an a .epub file

    My .htaccess file contains this – anything wrong here?
    I have the mod_rewrite “on”, and have put the AddType command at the bottom (after the test site gumph).

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    AuthType Basic
    AuthName "Test site"
    AuthUserFile "/home/joannast/.htpasswds/public_html/passwd"
    require valid-user
    
    AddType application/epub+zip .epub
    AddType application/x-mobipocket-ebook .mobi
Viewing 7 replies - 1 through 7 (of 7 total)
  • I will hallelujah anyone who has a clue: I will have stumbled at the last hurdle if I can’t find an answer…

    Are the epubs uploaded into WordPress like you did images, or are they just also on the server and linked to?

    Uploaded to Media. I tweaked to allow this.

    i.e.
    /wp-content/uploads/2011/04/TLE_Sony.epub

    (Apologies for my disappearance there – it’s my dinner time – I went away to chomp…)

    S’okay. You can just edit your original post, BTW, within the first hour or so, instead of double posting.

    I would ping your host and ask if you can host .epub files. They may have special considerations to force the right kind of download.

    Also I would put this

    AuthType Basic
    AuthName "Test site"
    AuthUserFile "/home/joannast/.htpasswds/public_html/passwd"
    require valid-user
    
    AddType application/epub+zip .epub
    AddType application/x-mobipocket-ebook .mobi

    ABOVE the normal calls to WordPress.

    The podpress plugin can offer epub available for download in a post. However, you have to upload the epub separately, manually.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to alter .htaccess to fix .epub downloads’ is closed to new replies.