• Resolved csb1024

    (@csb1024)


    It appears to be a problem with NGINX rewrite rules for WebP display.

    I got the following error when running nginx -t : – invalid parameter “final” in /usr/local/nginx/conf/vhost/www.xxx.com.conf:127

    Current recommended NGINX rules by us:

     # BEGIN Imagify: rewrite rules for webp
    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 final;
    	}
    }
    # END Imagify: rewrite rules for webp
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP Media

    (@wp_media)

    Hi @csb1024

    ?Sorry to hear about the issue! Yes, this code can be problematic in some cases (we expect to update it so the proper one is delivered).

    Removing “final” from it should fix the problem. Make sure to restart NGINX after making the change. So the final code would look like this:

    # BEGIN Imagify: rewrite rules for webp
    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;
    	}
    }
    # END Imagify: rewrite rules for webp

    ?Let us know if you need any further assistance, we are happy to help.

    Best Regards

    Thread Starter csb1024

    (@csb1024)

    @wp_media thanks, del “final”, work well!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WebP rewrite rules from NGINX issue’ is closed to new replies.