This snippet detects if the browser support WebP images and then serves a .webp image instead of jpg/png if a .webp file is available at the same location as the supplied jpg/png/gif
<IfModule mod_rewrite.c>
RewriteEngine On
# Check if browser supports WebP images
RewriteCond %{HTTP_ACCEPT} image/webp
# Check if WebP replacement image exists
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
# Serve WebP image instead
RewriteRule (.+)\.(jpe?g|png|gif)$ $1.webp [T=image/webp,E=REQUEST_image]
</IfModule>
<IfModule mod_headers.c>
# Vary: Accept for all the requests to jpeg, png and gif
Header append Vary Accept env=REQUEST_image
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
Thread Starter
MM
(@lblc)
Thank you very much for your answer.
I will get back to you as soon as possible to tell you if everything works.
Have a good weekend!
Thread Starter
MM
(@lblc)
Hello,
Here is my feedback, the code was well written in the .htaccess but it changes absolutely nothing. Unfortunately it still doesn’t work. I think the easiest way is that I uninstall your plugin and look for another one.
Can you tell me how to uninstall it properly? Thank you!
Hi,
The images will only appear in the image interface if they are not optimised. If they are not showing there it is because they have already been optimised. To remove the plugin, goto the Settings tab, click wipe settings and then deactivate and delete on the plugins page.
Thread Starter
MM
(@lblc)
Thank you for your feedback.
I understood very well how the interface works ,)
I confirm that in my case, the images do not appear in the wp-optimize dashboard, even the new ones I import. So I go through the media folder of WP to optimize them but it does, they are not marked as optimized and I do not see the optimization.
To check, I have to go to the wp-content/ folder on my server.
And anyway, the optimizations are not taken into account on my site, online.
In short, it doesn’t work for me!
Would you be able to provide your site URL so I can take a look?