Skip to content

Instantly share code, notes, and snippets.

@ThatGuySam
Created November 13, 2014 15:32
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 ThatGuySam/f14bfc170c6c1432387f to your computer and use it in GitHub Desktop.
Save ThatGuySam/f14bfc170c6c1432387f to your computer and use it in GitHub Desktop.
<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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment