4

If I serve a file named image.jpg the header content-type is sent as image/jpeg, but if I make a softlink named image that points to image.jpg the content-type is sent as text/plain.

Is there a way to send the same content type as if it were reading the original file?

Zequez
  • 157
  • 2
  • 6

1 Answers1

3

The content-type is determined by the mappings in the MIME-Magic file supplied with apache. This has a mapping for *.jpg to image/jpeg.

You can force the content-type inside a container, like so:

<Location /URI/of/images>
   ForceType image/jpeg
</Location>

http://httpd.apache.org/docs/2.2/mod/core.html#forcetype

adaptr
  • 16,576
  • 23
  • 34
  • Thanks! But not all the images are jpeg. Although if I can't find a solution I guess I could make 3 directories for png/gif/jpg and iterate them with RewriteRule. But I would need to change the code that generates the symlinks and I would want to avoid that. – Zequez Feb 24 '12 at 11:46
  • If there are specific filetypes, you can add a block for each of the real locations (which you must provide access to regardless, since the files are symlinked) – adaptr Feb 24 '12 at 12:02
  • The problem is that the images and symlinks are generated dynamically so that wouldn't be practical. – Zequez Feb 24 '12 at 12:23
  • In the other hand I just need to return the Content-Type of an image, it actually doesn't matter the exact type, so I guess ForceType is going to be enough. – Zequez Feb 24 '12 at 12:26