Passthrough <filname> .png to <filename> 8.png if IE <= 6 and <filename> 8.png exists
I just found out that converting PNG32 to PNG8 via Photoshop will fix PNG transparency bug in IE <= 6.
So, I thought that instead of serving PNG32 for all browsers, why not use PNG8 if the client is using IE <= 6.
I'm not much of an expert when it comes to htaccess / httpd directives, so I'm here for help.
The name is the psuedocode itself.
+1
source to share
2 answers
I haven't really tried this, but I think it should work:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4.0\ \(compatible;\ MSIE\ [1-6]\.
RewriteCond %{REQUEST_FILENAME} ^(.+)(\.png)$
RewriteCond %18%2 -f
RewriteRule ^(.+)\.png$ $18.png [L,QSA]
The first line includes mod_rewrite (and can be omitted if you've already done so). The second filter is IE <= 6. The third is basically to strip the filename for the fourth line, which checks if the file <filename> 8.png exists. The fifth line is redirecting.
+7
source to share