
# BEGIN ShortPixelWebp
# The directives (lines) between "BEGIN ShortPixelWebp" and "END ShortPixelWebp" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

           <IfModule mod_rewrite.c>
           RewriteEngine On
RewriteOptions Inherit
           ##### Directives for delivering AVIF files, if they exist #####
           # Does the browser support avif?
           RewriteCond %{HTTP_ACCEPT} image/avif
           # AND is the request a JPG, PNG, or WebP? (no GIFs because the animation is sometimes lost in AVIF);
		   # WebP is included on purpose: an .avif only exists when it came out smaller, so
		   # serving it also pays off for WebP files uploaded straight to the media library.
		   # (also grab the basepath %1 to match in the next rule)
           RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png|webp)$
           # AND does a .avif image exist?
           RewriteCond %{DOCUMENT_ROOT}/%1.avif -f
           # THEN send the avif image and set the env var avif
           RewriteRule (.+)\.(?:jpe?g|png|webp)$ $1.avif [NC,T=image/avif,E=avif,L]

           # Does the browser support avif?
           RewriteCond %{HTTP_ACCEPT} image/avif
           # AND is the request a JPG, PNG, or WebP? (no GIFs because the animation is sometimes lost in AVIF);
		   # (also grab the basepath %1 to match in the next rule)
           RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png|webp)$
           # AND does a .jpg.avif image exist?
           RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.avif -f
           # THEN send the avif image and set the env var avif
           RewriteRule ^(.+)$ $1.avif [NC,T=image/avif,E=avif,L]

           </IfModule>
           <IfModule mod_headers.c>
           <FilesMatch "\.(avif)$">
               Header set Cache-Control "max-age=31536000, public"
           </FilesMatch>
           </IfModule>
           <IfModule mod_mime.c>
               AddType image/avif .avif
           </IfModule>
                 
           <IfModule mod_rewrite.c>
             RewriteEngine On
RewriteOptions Inherit
             ##### TRY FIRST the file appended with .webp (ex. test.jpg.webp) #####
             # Does the browser support webp? Only the Accept header decides: a
             # user-agent match would also hand webp to a client that asked for
             # "Accept: image/jpeg", and no Vary value can describe that.
             RewriteCond %{HTTP_ACCEPT} image/webp
             # AND is the request a jpg, png, or gif?
             RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png|gif)$
             # AND does a .ext.webp image exist?
             RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.webp -f
             # THEN send the webp image and set the env var webp
             RewriteRule ^(.+)$ $1.webp [NC,T=image/webp,E=webp,L]
             ##### IF NOT, try the file with replaced extension (test.webp) #####
             RewriteCond %{HTTP_ACCEPT} image/webp
             # AND is the request a jpg, png, or gif? (also grab the basepath %1 to match in the next rule)
             RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png|gif)$
             # AND does a .webp image exist?
             RewriteCond %{DOCUMENT_ROOT}/%1.webp -f
             # THEN send the webp image and set the env var webp
             RewriteRule (.+)\.(?:jpe?g|png|gif)$ $1.webp [NC,T=image/webp,E=webp,L]
           </IfModule>
           <IfModule mod_headers.c>
             <FilesMatch "\.(webp)$">
               Header set Cache-Control "max-age=31536000, public"
             </FilesMatch>
           </IfModule>
           <IfModule mod_mime.c>
             AddType image/webp .webp
           </IfModule>
           
           <IfModule mod_headers.c>
             <FilesMatch "\.(jpe?g|png|gif|webp|avif)$">
               Header append Vary Accept
             </FilesMatch>
           </IfModule>
           
# END ShortPixelWebp