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.
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.