Apache Server configuration support - .htaccess ForceType unnecessary for images?

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2007 > .htaccess ForceType unnecessary for images?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author .htaccess ForceType unnecessary for images?
Lawrence San

2007-08-24, 7:19 pm

I was reading in the Apache 1.3 docs and elsewhere about .htaccess
ForceType, which lets you specify all the files in a given directory as
being of a certain type (like HTML, or GIF, or whatever) without having
to use a dot extension on the URL. A page I read at the W3C actually
recommended constructing URIs this way (with no dot extension) but
keeping the dot extension on the files themselves; other things I've
seen suggested even that wasn't necessary.

Curious about this, I constructed a simple HTML file containing an img
tag pointing to a JPEG. I named the JPEG file simply "01" and specified
it in the HTML page using <img src="01">. This was just a baseline test;
since I hadn't entered ForceType (or any other content descriptor) in
the directory's .htaccess file, I assumed the graphic would fail to load.

To my amazement, it loaded fine in every browser I tried: Mac Firefox
and Safari, Windows IE6 and even Windows IE5.01.

I assume the browsers guessed it was an image because it was in an img
tag, but even so, how did the browser know to render it as a JPEG, and
not a GIF or PNG -- or as text, since that's apparently what Apache sent
it as? (From Mac Firefox 2, the http request header said "Accept
image/png,*/*;q=0.5", and from Apache 1.3.37 on FreeBSD, the http
response header said "Content-Type text/plain".)

Does this mean ForceType (or other content negotiation, MIME stuff,
etc.) is unnecessary for images? You can just omit the dot extension
both from the files and URLs, and don't need to put anything special in
the .htaccess files?

--
Lawrence San
Cartoon Stories for Thoughtful People:
<http://www.sanstudio.com>
patpro ~ patrick proniewski

2007-08-24, 7:19 pm

In article <lawrencesan-C4AC0C.19174924082007@news.verizon.net>,
Lawrence San <lawrencesan@gmail.com> wrote:

> To my amazement, it loaded fine in every browser I tried: Mac Firefox
> and Safari, Windows IE6 and even Windows IE5.01.
>
> I assume the browsers guessed it was an image because it was in an img
> tag, but even so, how did the browser know to render it as a JPEG, and
> not a GIF or PNG -- or as text, since that's apparently what Apache sent
> it as? (From Mac Firefox 2, the http request header said "Accept
> image/png,*/*;q=0.5", and from Apache 1.3.37 on FreeBSD, the http
> response header said "Content-Type text/plain".)


Most modern browsers will look into the file to determine its type. Into
the past it has even yield to some interesting security holes in IE.

> Does this mean ForceType (or other content negotiation, MIME stuff,
> etc.) is unnecessary for images? You can just omit the dot extension
> both from the files and URLs, and don't need to put anything special in
> the .htaccess files?


older browsers will fail on this. Back in the mid 90's when I've created
my first web sites on my Mac, I didn't use any file extensions for
images, and they wouldn't load on windows browsers (for example).

patpro

--
http://www.patpro.net/
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com