Rewrite image to webP not working
-
Hello,
I use the rewrite mode to have my jpg|png|gif etc…. images loaded in webp.
Unfortunately when I go to network and inspect the page I can see that it doesn’t work and the images are still loaded in their original format.
I don’t use a CDN and the webp images exist.
Here’s what’s been added to the htaccess :
# BEGIN Imagify: rewrite rules for avif <IfModule mod_setenvif.c> # Vary: Accept for all the requests to jpeg, png, and gif. SetEnvIf Request_URI "\.(jpg|jpeg|jpe|png|gif|webp)$" REQUEST_image </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Check if browser supports AVIF images. # Update the MIME type accordingly. RewriteCond %{HTTP_ACCEPT} image/avif # Check if AVIF replacement image exists. RewriteCond %{REQUEST_FILENAME}.avif -f # Serve AVIF image instead. RewriteRule (.+)\.(jpg|jpeg|jpe|png|gif|webp)$ $1.$2.avif [T=image/avif,NC] </IfModule> <IfModule mod_headers.c> # Update the MIME type accordingly. Header append Vary Accept env=REQUEST_image </IfModule> # END Imagify: rewrite rules for avif # BEGIN Imagify: rewrite rules for webp <IfModule mod_setenvif.c> # Vary: Accept for all the requests to jpeg, png, and gif. SetEnvIf Request_URI "\.(jpg|jpeg|jpe|png|gif)$" REQUEST_image </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Check if browser supports WebP images. RewriteCond %{HTTP_ACCEPT} image/webp # Check if WebP replacement image exists. RewriteCond %{REQUEST_FILENAME}.webp -f # Serve WebP image instead. RewriteRule (.+)\.(jpg|jpeg|jpe|png|gif)$ $1.$2.webp [T=image/webp,NC] </IfModule> <IfModule mod_headers.c> Header append Vary Accept env=REQUEST_image </IfModule> # END Imagify: rewrite rules for webp
Can you tell me what’s wrong?
Thanks in advance, I’ve tried everything.
The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Rewrite image to webP not working’ is closed to new replies.