Page 1 of 1

Apache mime types

Posted: Mon May 29, 2017 1:36 pm
by mrpasini
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".

Re: Apache mime types

Posted: Tue May 30, 2017 11:45 am
by joemuller
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

Re: Apache mime types

Posted: Tue May 30, 2017 11:58 am
by mrpasini
Ah, I spaced out there, didn't I? Thanks.

[pause]

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".

Re: Apache mime types

Posted: Tue May 30, 2017 12:08 pm
by joemuller
D'oh! On further testing, the magic incantation is as follows: (needs to have a leading '.')

Code: Select all

AddType application/json .json

Re: Apache mime types

Posted: Tue May 30, 2017 12:48 pm
by mrpasini
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.

Re: Apache mime types

Posted: Wed May 31, 2017 2:00 pm
by drew.phillips
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?

Re: Apache mime types

Posted: Wed May 31, 2017 2:13 pm
by mrpasini
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.