# Vary: Accept for all the requests to jpeg and png SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image RewriteEngine On # If the Browser supports WebP images, and the .webp file exists, use it. RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_URI} ^/?storage/.*\.(jpe?g|png) RewriteCond %{REQUEST_FILENAME}.webp -f RewriteRule ^/?(.*)$ $1.webp [NC,T=image/webp,END] {% if auto_convert %} # If the Browser supports WebP images, and the .webp file does not exist, generate it. RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_URI} ^/?storage/.*\.(jpe?g|png) RewriteCond %{REQUEST_FILENAME}\.webp !-f RewriteRule ^/?(.*)$ plugins/offline/responsiveimages/webp.php?path=$1 [NC,END] {% endif %} Header append Vary Accept env=REQUEST_image AddType image/webp .webp