WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] htaccess editing (7 posts)

  1. Bad_Egg
    Member
    Posted 2 years ago #

    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.

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Your host would need to support these mime types.

  3. Bad_Egg
    Member
    Posted 2 years ago #

    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

  4. MickeyRoush
    Member
    Posted 2 years ago #

    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>

  5. Bad_Egg
    Member
    Posted 2 years ago #

    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

  6. MickeyRoush
    Member
    Posted 2 years ago #

    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.

  7. Bad_Egg
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic