Forum

Serving WebP images in Hiawatha

Fred
11 January 2017, 20:56
Hi Hugo,

I would like to to serve WebP images to visitors with supported browsers..
Could you please help ple convert the rule bellow to Hiawatha format?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
RewriteCond %{REQUEST_FILENAME}\.webp -f
RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp


Thank you in advance
Fred
Fred
18 January 2017, 00:20
I know this is more regular expression than hiawatha but i'll appreciate any help please
Hugo Leisink
18 January 2017, 17:47
I don't know if I understood the goal of that rewrite rule correctly, but I guess it must be something like this:
UrlToolkit {
ToolkitID = webp
Header Accept !image/webp Return
Match !.*\.(jpe?g|png)$ Return
RequestURI Exists Skip 1
Do Return
Match (*.+\.(jpe?g|png))$ Rewrite $1.webp
}
This topic has been closed.