Skip to content

Instantly share code, notes, and snippets.

@sergejmueller
Last active January 12, 2024 20:58
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sergejmueller/5500879 to your computer and use it in GitHub Desktop.
Save sergejmueller/5500879 to your computer and use it in GitHub Desktop.
Apache: Detecting WebP support with Header Vary Accept
<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>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp
@jslegers
Copy link

jslegers commented Dec 9, 2015

What exactly is this code supposed to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment