Skip to content

Instantly share code, notes, and snippets.

@nuno
Forked from sergejmueller/.htaccess
Created February 18, 2014 15:37
Show Gist options
  • Save nuno/9073284 to your computer and use it in GitHub Desktop.
Save nuno/9073284 to your computer and use it in GitHub Desktop.
Extension of the Apache system. Htaccess file for browser-based delivery of WebP instead of JPEG image files. Especially for WordPress. More information about WebP and the snippet shown below http://cup.wpcoder.de/webp-jpeg-alternative/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule ^(wp-content/uploads.+)\.(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