Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created December 11, 2020 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lukecav/597c9129851fc653b92c6e108145705a to your computer and use it in GitHub Desktop.
Save lukecav/597c9129851fc653b92c6e108145705a to your computer and use it in GitHub Desktop.
Smush Pro plugin WebP conversions rules for .htacess for Apache
# BEGIN SMUSH-WEBP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/wp-content/smush-webp/disable_smush_webp !-f
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{DOCUMENT_ROOT}/wp-content/smush-webp/$1.$2.webp -f
RewriteRule ^/?(.+)\.(jpe?g|png)$ /wp-content/smush-webp/$1.$2.webp [NC,T=image/webp,E=WEBP_image]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=WEBP_image
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
# END SMUSH-WEBP