How to serve webp Images in the sites hosted at Cloudways?

Hi guys,
I wanted to use WebP Express to serve images on webp but after chatting with the support they mentioned adding some code to .htaccess but still couldn’t enable it.
It’s showing some error. Please check the screenshot.
Thanks

Sadly, wrong information provided by them. It will not work because hybrid combination. They use NGINX for static files. So, .htaccess will not work.

Here’s what you need to do.

  1. Open a support ticket (not live chat)
  2. Ask to add NGINX snippet

That’s it.

1 Like

They asked me to add this snippet to htaccess but still, the error is same.
# BEGIN Imagify: rewrite rules for webp

# Vary: Accept for all the requests to jpeg, png, and gif.
SetEnvIf Request_URI “.(jpg|jpeg|jpe|png|gif)$” REQUEST_image


RewriteEngine On
RewriteBase /
# Check if browser supports WebP images.
RewriteCond %{HTTP_ACCEPT} image/webp
# Check if WebP replacement image exists.
RewriteCond %{DOCUMENT_ROOT}/$1.$2.webp -f
# Serve WebP image instead.
RewriteRule (.+).(jpg|jpeg|jpe|png|gif)$ $1.$2.webp [T=image/webp]


Header append Vary Accept env=REQUEST_image

# END Imagify: rewrite rules for webp
# BEGIN Imagify: webp file type

AddType image/webp .webp

# END Imagify: webp file type

Please read this.

You need to ask them to login server via root user and enter below snippet

# WebP Express rules
# --------------------
location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
  add_header Vary Accept;
  expires 365d;
  if ($http_accept !~* "webp"){
    break;
  }
  try_files
    /wp-content/webp-express/webp-images/doc-root/$uri.webp
    $uri.webp
    /wp-content/plugins/webp-express/wod/webp-on-demand.php?xsource=x$request_filename&wp-content=wp-content
    ;
}

# Route requests for non-existing webps to the converter
location ~* ^/?wp-content/.*\.(png|jpe?g)\.webp$ {
    try_files
      $uri
      /wp-content/plugins/webp-express/wod/webp-realizer.php?wp-content=wp-content
      ;
}
# ------------------- (WebP Express rules ends here)