2
0
Fork 0
mirror of https://github.com/phanan/htaccess.git synced 2018-11-08 13:39:40 +01:00

Added snippet for "Serving WebP images"

This commit is contained in:
Vincent Orback 2015-02-16 16:40:38 +01:00
parent c1d5886fae
commit 5a2a7927c0

View file

@ -425,3 +425,16 @@ AddHandler application/x-httpd-php55 .php
# Alternatively, you can use AddType
AddType application/x-httpd-php55 .php
```
### Serve WebP images
If WebP images are supported and an image with a .webp extension is located as the same place as the jpg/png image that is going to be served, then the WebP image is served instead.
``` apacheconf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
```
[Source](https://github.com/vincentorback/WebP-images-with-htaccess)