• Resolved Bad_Egg

    (@bad_egg)


    I have amended the code in my WordPress theme to allow upload of ePub and mobi files. So far so good. Unfortunately, Mac users get jabberwocky instead of the file. Research indicates I am to edit the .htaccess file to add:

    AddType application/epub+zip .epub
    AddType application/x-mobipocket-ebook .mobi

    Problem is, I’m not entirely sure if I add it after the standard code or somewhere before its closing tag. This is the standard WordPress htaccess code:

    # BEGIN WordPress
    IfModule mod_rewrite.c
    RewriteEngine On
    RewriteBase /globalindieauthor/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /globalindieauthor/index.php [L]
    /IfModule
    # END WordPress

    Where should I add the new code? Do I add it on lines before /IfModule? Or somewhere else?

    Any help appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Your host would need to support these mime types.

    Thread Starter Bad_Egg

    (@bad_egg)

    Hi Swanson:

    I think they must because I have already uploaded them. Windows users can download fine. It’s just Mac. This is what I found on the same site that taught me how to amend the code to upload the mobi and epub files:

    The problem is that while Windows handles the misidentified .epub files fine, Macs freak out and show you the binary. You click it on a Mac and see garbage. Not cool. Must fix.

    I found this post in the WebFaction support on adding epub to the .htaccess file to change content-type by file extension. A bit of modification and I found adding this to the application root .htaccess file did the trick

    AddType application/epub+zip .epub
    AddType application/x-mobipocket-ebook .mobi

    A word of caution – BE CAREFUL WITH YOUR HTACCESS file! It probably already exists so be sure to download-backup-modify-upload-via-ssh for maximum security. Or really sFTP is plenty secure as well.

    I had a friend on Mac try to download the file and she got jabberwocky. So now I am trying to edit the htaccess so this problem can be averted.

    Thanks

    Bad_Egg wrote:

    Problem is, I’m not entirely sure if I add it after the standard code or somewhere before its closing tag. This is the standard WordPress htaccess code:

    It needs to be near the top of your .htaccess file above the WordPress permalinks rules.

    If that doesn’t work, you could also try ForceType. It really depends on your server setup.

    <FilesMatch “\.epub$”>
    ForceType application/epub+zip
    </FilesMatch>
    <FilesMatch “\..mobi$”>
    ForceType application/x-mobipocket-ebook
    </FilesMatch>

    Thread Starter Bad_Egg

    (@bad_egg)

    Thanks. Have added the first recommended code and will see if that works. If not, will try this ForceType option. Funny thing is, even without the code the downloads are working for some Mac users. I guess it depends on their browser and/or OS maybe?

    BTW, when you say “above the WordPress permalink rules” does this mean before the “IfModule” or before “# BEGIN WordPress”?

    Cheers,
    Michelle

    Bad_Egg wrote:

    BTW, when you say “above the WordPress permalink rules” does this mean before the “IfModule” or before “# BEGIN WordPress”?

    At the very top, before everything, if it’s possible. So, put it before # BEGIN WordPress for sure.

    Thread Starter Bad_Egg

    (@bad_egg)

    Thanks. Some Mac users have reported they can download fine; hopefully this will work for the rest.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘htaccess editing’ is closed to new replies.