Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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

share|improve this answer
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 <FilesMatch> 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.