Apache mime types

Web hosting discussion, programming, and shared and dedicated servers.
7 posts Page 1 of 1
by mrpasini » Mon May 29, 2017 1:36 pm
Thought I could just add "Add Type application/json json" to .htaccess and be done with it but when I curl my json feed I see it is still "Content-Type: text/plain" so I'm wondering how to get Apache to serve json files as "Content-Type: application/json".
by joemuller » Tue May 30, 2017 11:45 am
Per the Apache documentation, it looks like the directive is 'AddType' instead of 'Add Type'.

Try this out: (fixed to include the .json extension)

Code: Select all

AddType application/json .json

-- Joe
I'm a proud employee of Sonic.net! :-)
by mrpasini » Tue May 30, 2017 11:58 am
Ah, I spaced out there, didn't I? Thanks.


I made the correction but I'm still getting "Content-Type: text/plain" from curl on the json file "http://mikepasini.com/corners/index.json".
by joemuller » Tue May 30, 2017 12:08 pm
D'oh! On further testing, the magic incantation is as follows: (needs to have a leading '.')

Code: Select all

AddType application/json .json
I'm a proud employee of Sonic.net! :-)
by mrpasini » Tue May 30, 2017 12:48 pm
I've read that it should work either way (json or .json). But I can confirm it isn't working either way. Still getting "Content-Type: text/plain" where I need "Content-Type: application/json" for the feed to be parsed by third party readers.
by drew.phillips » Wed May 31, 2017 2:00 pm
It looks like the .htaccess rule is the same but it does appear to be working:

Code: Select all

curl -v http://mikepasini.com/corners/index.json
*   Trying 64.x.x.x...
* Connected to mikepasini.com (64.x.x.x) port 80 (#0)
> GET /corners/index.json HTTP/1.1
> Host: mikepasini.com
> User-Agent: curl/7.47.0
> Accept: */*
< HTTP/1.1 200 OK
< ...snip
< Content-Length: 22171
< Content-Type: application/json

Are you still having problems with the feed content type being recognized correctly everywhere?
Drew Phillips
Programmer / System Operations, Sonic.net
by mrpasini » Wed May 31, 2017 2:13 pm
It's working correctly since I moved it into the folder with the domain name. I'd tried that before but without the dot in the file extension. Here's the proof:

http://json-feed-viewer.herokuapp.com/f ... index.json

I thought I replied to the thread on that yesterday but I don't see my message. Sorry! And thanks for helping to sort it out.
7 posts Page 1 of 1

Who is online

In total there are 5 users online :: 0 registered, 0 hidden and 5 guests (based on users active over the past 5 minutes)
Most users ever online was 700 on Thu Jun 18, 2020 12:00 pm

Users browsing this forum: No registered users and 5 guests