[ad_1]
As caching plugins like WP Rocket and Flying Press, possible others only checking WebP support, and push only WebP (if supported).
So my rewrite now is doing to push generated AVIFs for my client when browser supports that:
# Rewrite AVIFs
<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
You can safely add that into your plugin, that rewrite is working in main WordPress folder.
The page I need help with: [log in to see the link]