Skip to content

Instantly share code, notes, and snippets.

@landsman
Created December 9, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landsman/41650b665bda507c3cacf8911de6e5ec to your computer and use it in GitHub Desktop.
Save landsman/41650b665bda507c3cacf8911de6e5ec to your computer and use it in GitHub Desktop.
webp pres htacesss - drupal coloseum
<IfModule mod_rewrite.c>
RewriteEngine On
# Check if browser support WebP images
RewriteCond %{HTTP_ACCEPT} image/webp
# Check if WebP replacement image exists
RewriteCond %{DOCUMENT_ROOT}/$1.$2.webp -f
# Serve WebP image instead
RewriteRule (.+)\.(jpe?g|png)$ $1.$2.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp
https://www.drupal.org/project/webp
https://www.drupal.org/project/imageapi_optimize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment