WordPress.org

Ready to get started?Download WordPress

Forums

How to alter .htaccess to fix .epub downloads (8 posts)

  1. ashbydesign
    Member
    Posted 3 years ago #

    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
  2. ashbydesign
    Member
    Posted 3 years ago #

    I will hallelujah anyone who has a clue: I will have stumbled at the last hurdle if I can't find an answer...

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

  4. ashbydesign
    Member
    Posted 3 years ago #

    Uploaded to Media. I tweaked to allow this.

  5. ashbydesign
    Member
    Posted 3 years ago #

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

  6. ashbydesign
    Member
    Posted 3 years ago #

    (Apologies for my disappearance there - it's my dinner time - I went away to chomp...)

  7. 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.

  8. blau
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic