Skip to content

Instantly share code, notes, and snippets.

@sebastianmoran-mainwp
Created December 10, 2020 21:25
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 sebastianmoran-mainwp/5059fecca40906d08fd32a316dfc0fe3 to your computer and use it in GitHub Desktop.
Save sebastianmoran-mainwp/5059fecca40906d08fd32a316dfc0fe3 to your computer and use it in GitHub Desktop.
Smush Pro WebP conversion rules 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment