Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Forked from sergejmueller/.htaccess
Created August 2, 2013 10:29
Show Gist options
  • Save cheeyeo/6138937 to your computer and use it in GitHub Desktop.
Save cheeyeo/6138937 to your computer and use it in GitHub Desktop.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !(Chrome\/[0-8]|Android\s[0-3])\.
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment