Welcome! Log In Create A New Profile

Advanced

Redirection PNG, JPG to WebP

Posted by ignace72 
Redirection PNG, JPG to WebP
February 17, 2021 08:45AM
Good morning all.
I want to redirect all my PNG and JPG images to their WebP versions. I tried several versions of the code, but each time no more images appear.
This is the last code I used:
location ~ * ^ (/.+) \. (jpg | jpeg | jpe | png | gif) $ {
add_header Vary Accept;

if ($ http_accept ~ * "webp") {
set $ imwebp A;
}
if (-f $ request_filename.webp) {
set $ imwebp "$ {imwebp} B";
}
if ($ imwebp = AB) {
rewrite ^ (. *) $ 1.webp;
}
}
If anyone has an idea to solve my problem?
Thank you.
Ignace.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 319
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready