I'm using some default images to show users the type of document that is used.
e.g. this image to show there is a .png file
In the /osr/icons/mime/
folder I have images for a multitude of files, e.g. avi.png
, html.png
, jpg.png
, ...
So I simply need to get the file extension for my current document, for example png
and display /osr/icons/mime/png.png
In case there is a file-format I don't have a predefined image, I'm using a rewrite condition to automatically show a generic image.
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} /osr/icons/mime/(.*).(gif|jpg|jpeg|png)$
RewriteRule ^(.*) /osr/icons/mime/generic.png
This works fine, except if the extension of a document is uppercase, e.g. .PNG
instead of .png
. In this case my code tries to display /osr/icons/mime/PNG.png
which does not exist, an therefore shows the generic image.
Is there a way to change the RewriteCond/Rule to fallback to the lowercase image?
I found How do I do a case-insensitive mod_rewrite redirect to the same URL (mod case)? which recommends RewriteMap insensitive tolower:
but I don't exactly know if/how this would work for me.
Using [NC]
didn't work either.
I know of the following work-arounds, which I don't really want to use:
- Switching to case-insensitiv file handling for the folder
- Dublicating List item all files in the folder to uppercase names (would not take
.Png
into account) - Rewriting the code that loads the image file to automatically use lowercase