Skip to content

Instantly share code, notes, and snippets.

View JosephSilber's full-sized avatar

Joseph Silber JosephSilber

View GitHub Profile
@sergejmueller
sergejmueller / .htaccess
Last active October 9, 2024 00:33
Apache: Detecting WebP support with Header Vary Accept
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>