<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# BEGIN WPC Serve WebP
# The directives (lines) between "BEGIN WPC Serve WebP" and "END WPC Serve WebP" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/avif
RewriteCond %{REQUEST_URI} ^(.+)\.(jpe?g|png|gif)$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.avif -f
RewriteRule ^(.+)$ $1.avif [E=avif,L]
RewriteCond %{HTTP_ACCEPT} image/avif
RewriteCond %{REQUEST_URI} ^(.+)\.(jpe?g|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/%1.avif -f
RewriteRule ^(.+)\.(jpe?g|png|gif)$ $1.avif [E=avif,L]
RewriteCond %{HTTP_ACCEPT} image/webp [OR]
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights"
RewriteCond %{HTTP_USER_AGENT} !Edge/17
RewriteCond %{REQUEST_URI} ^(.+)\.(jpe?g|png|gif)$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.webp -f
RewriteRule ^(.+)$ $1.webp [E=webp,L]
RewriteCond %{HTTP_ACCEPT} image/webp [OR]
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights"
RewriteCond %{HTTP_USER_AGENT} !Edge/17
RewriteCond %{REQUEST_URI} ^(.+)\.(jpe?g|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/%1.webp -f
RewriteRule ^(.+)\.(jpe?g|png|gif)$ $1.webp [E=webp,L]
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
AddType image/avif .avif
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_webp
Header append Vary Accept env=REDIRECT_avif
</IfModule>

# END WPC Serve WebP

# Enable GZIP
<IfModule mod_deflate.c>
# Activate Compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Do not compress uncompresible content
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp|pdf)$ no-gzip dont-vary
</IfModule>
</IfModule>

# Compress All output with MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
		                          application/javascript \
		                          application/json \
		                          application/rss+xml \
		                          application/vnd.ms-fontobject \
		                          application/x-font-ttf \
		                          application/xhtml+xml \
		                          application/xml \
		                          font/opentype \
		                          image/svg+xml \
		                          image/x-icon \
		                          text/css \
		                          text/html \
		                          text/plain \
		                          text/x-component \
		                          text/xml
</IfModule>
<IfModule mod_headers.c>
Header append Vary: Accept-Encoding
</IfModule>
</IfModule>

