Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Created September 27, 2023 08:33
Show Gist options
  • Save sabrina-zeidan/d1e1838cab832a48f36a8489bc818def to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/d1e1838cab832a48f36a8489bc818def to your computer and use it in GitHub Desktop.
webp redirection on nexcess servers
RewriteEngine On
# Check if the request is for a PNG or JPEG file
RewriteCond %{REQUEST_FILENAME} \.(png|jpe?g)$
# Check if a WebP version of the file exists
RewriteCond %{REQUEST_FILENAME}.webp -f
# Redirect to the WebP version of the file
RewriteRule ^(.+)\.(png|jpe?g)$ $1.$2.webp [NC,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment