#### BEGIN atec-webp
# DO NOT EDIT THESE LINES

<IfModule mod_mime.c>
	# Ensure .webp is served with correct MIME type
	AddType image/webp .webp
</IfModule>

<IfModule mod_headers.c>
	# Let caches know compression may vary
	<FilesMatch "\.webp$">
		Header set Vary "Accept-Encoding"
	</FilesMatch>
	
	Header unset Vary env=dont-vary
	Header set Vary "Accept" "expr=%{REQUEST_URI} =~ m#\.(webp|jpe?g|png|gif|bmp)$#"
</IfModule>

<IfModule mod_rewrite.c>
	RewriteEngine On

	# Match images
	RewriteCond %{REQUEST_URI} \.(jpe?g|png|gif|bmp)$ [NC]

	# 1. Serve .Xwebp.webp
	RewriteCond %{REQUEST_FILENAME}.Xwebp.webp -f
	RewriteRule ^(.+)$ $1.Xwebp.webp [T=image/webp,E=no-gzip:1,E=no-brotli:1,E=dont-vary:1,L]

	# 2. Serve plain .webp
	RewriteCond %{REQUEST_FILENAME}.webp -f
	RewriteRule ^(.+)$ $1.webp [T=image/webp,E=no-gzip:1,E=no-brotli:1,E=dont-vary:1,L]

	# 3. Fallback to converter
	RewriteRule ^(.+\.(jpe?g|png|gif|bmp))$ atec-webp/img2webp.php?src=$1 [QSA,E=no-gzip:1,E=no-brotli:1,E=dont-vary:1,L]
</IfModule>

#### END atec-webp