… or “how to serve different image types at one URL.”
… or “why I let myself get carried away reading from one blog post to another.”
After discovering free and cheap SSL certificates, I was playing with some sites over HTTPS to see what different browsers would show for the security. Very quickly, I noticed that having any elements on the page that aren’t loaded over HTTPS causes the whole page to be marked as not secured. One element in particular on one page was this “valid” icon from w3.org. Note that the URL, http://www.w3.org/Icons/valid-xhtml10-blue, doesn’t have any file-type extension on it. Since w3.org doesn’t provide the icon over HTTPS (though they are fine with hotlinking the HTTP version), I needed to move it to my own server. I went to look for the image file and didn’t find a “valid-xhtml10-blue” file with no extension. What I found were several files with that base name and different extensions. I couldn’t find any information in the w3.org docs or in the source for the validator, which includes all the validation icons, as to how this was achieved. I googled to no avail.
Not long after that, I noticed an update for Bad Behavior was available and went to read the release notes. After reading the release notes, a post about the future major version of Bad Behavior caught my eye. In that post–no, actually in the comments on that post–there was a mention of getting rid of Apache for performance reasons. In reading that post, in the discussions of the pros and cons of nginx versus Apache, “content negotiation” was described, and suddenly I understood how to serve the multiple image file types at one type-extension-less URL, like w3.org did. A quick googling led me to MultiViews.
One line in an .htaccess file and it’s done:
Options +MultiViews
Comments 1
MultiViews is indeed the right option. It’s probably the only thing I’d actually like to see added to nginx at this point. So far I’ve had no trouble working around its absence, but it’s just such a cool feature, and of course it’s something people should do…
Posted 04 Nov 2009 at 1:34 pm ¶