Adding the XPI MIME Type for Firefox Extension Installs

By  on  

Yesterday I posted version 0.1 of the David Walsh Blog Toolbar for Firefox. Unfortunately that led to an awkward conversation with my .htaccess file.

.htaccess: I have no idea what to do with this.
me: I want the toolbar to install when they request this file.
.htaccess: Well, how am I supposed to do that?
me: OMG! You don't know?!
.htaccess: No, just like you didn't know how to create a Firefox extension before you did the research.
me: Good point. When can you research and start serving it up?
.htaccess: I can't research. I'm a file.
me: Oh. So I just need to figure things out for you again?
.htaccess: You never pay attention to me anymore...

That went on for quite a while but the moral of the story is that if you want your server to handle XPI files correctly, you need to add the following to your .htaccess file:

AddType application/x-xpinstall .xpi

If you don't add the above directive, Firefox will open the file as plain text which is an ugly mess.

Recent Features

  • By
    Send Text Messages with PHP

    Kids these days, I tell ya.  All they care about is the technology.  The video games.  The bottled water.  Oh, and the texting, always the texting.  Back in my day, all we had was...OK, I had all of these things too.  But I still don't get...

  • By
    Facebook Open Graph META Tags

    It's no secret that Facebook has become a major traffic driver for all types of websites.  Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly.  And of course there are Facebook "Like" and "Recommend" widgets on every website.  One...

Incredible Demos

  • By
    Translate Content with the Google Translate API and JavaScript

    Note:  For this tutorial, I'm using version1 of the Google Translate API.  A newer REST-based version is available. In an ideal world, all websites would have a feature that allowed the user to translate a website into their native language (or even more ideally, translation would be...

  • By
    “Top” Watermark Using MooTools

    Whenever you have a long page worth of content, you generally want to add a "top" anchor link at the bottom of the page so that your user doesn't have to scroll forever to get to the top. The only problem with this method is...

Discussion

  1. Only a web dev could have some kind of decent conversation with a file!

    I did wonder why it didn’t install when I clicked it, good to see you found out why though. The ever brilliant David saves the day!

  2. Awesome :)

    Is it just me or are .htaccess files getting increasingly uppity lately?

  3. You’re hilarious, dude! Have fun in Cali!!

  4. Facundo

    LOL! i used to have long talks whit .htaccess too.

  5. I envy your relationship with your .htaccess file.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!