Serve .json as content type application/json with Apache on Ubuntu


If you are using Ubuntu 10.04 or Debian and you serve .json files through Apache, you might want to serve the files with the correct content type. I am doing this primarily because I want to use the Firefox extension JSONView

The Apache module mod_mine will help to do this easily. However, with Ubuntu you need to edit the file /etc/mime.types and add the line

application/json json

Then restart Apache

sudo /etc/init.d/apache2 restart

Warning: count(): Parameter must be an array or an object that implements Countable in /home/public/blog/wp-includes/class-wp-comment-query.php on line 399

There are 2 comments in this article:

  1. 3/08/2011Rob McCardle say:

    Bingo, thanks man :)

  2. 30/04/2012Node.js require() for your browser | Pixels vs. Bytes say:

    […] is responsible for sending the right handler, so you might have to some configuration stuff here. Joshua Gourneau’s post on how add a JSON type to an Apache/Ubuntu server might be a good hint here (it’s easy […]

Write a comment: