# Rewrite AVIFs
<IfModule mod_headers.c>
<filesMatch "\.(webp|avif)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# Check if AVIF is supported by the browser
RewriteCond %{HTTP_ACCEPT} image/avif
# Check if the .avif file exists
RewriteCond %{DOCUMENT_ROOT}/$1.avif -f
# Serve the .avif file content for the .webp request
RewriteRule ^(wp-content/uploads/.+)\.webp$ $1.avif [T=image/avif,E=accept:avif,L]
</IfModule>
# Rewrite AVIFs END