JezK
Edit File: .htaccess
# MC4WP Start # Apache 2.2 <IfModule !authz_core_module> <Files mc4wp-debug-log.php> deny from all </Files> </IfModule> # Apache 2.4+ <IfModule authz_core_module> <Files mc4wp-debug-log.php> Require all denied </Files> </IfModule> # MC4WP End # BEGIN Wordfence code execution protection <IfModule mod_php5.c> php_flag engine 0 </IfModule> <IfModule mod_php7.c> php_flag engine 0 </IfModule> <IfModule mod_php.c> php_flag engine 0 </IfModule> AddHandler cgi-script .php .phtml .php3 .pl .py .jsp .asp .htm .shtml .sh .cgi Options -ExecCGI # END Wordfence code execution protection # BEGIN Register webp mime type <IfModule mod_mime.c> AddType image/webp .webp </IfModule> # END Register webp mime type # BEGIN WP-Optimize WebP Rules <IfModule mod_rewrite.c> RewriteEngine On # Redirect to existing converted image in same dir (if browser supports webp) RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_FILENAME} (?i)(.*)(\.jpe?g|\.png)$ RewriteCond %1%2\.webp -f RewriteRule (?i)(.*)(\.jpe?g|\.png)$ %1%2\.webp [T=image/webp,E=EXISTING:1,E=ADDVARY:1,L] # Make sure that browsers which does not support webp also gets the Vary:Accept header # when requesting images that would be redirected to webp on browsers that does. <IfModule mod_headers.c> <FilesMatch "(?i)\.(jpe?g|png)$"> Header append "Vary" "Accept" </FilesMatch> </IfModule> </IfModule> # Rules for handling requests for webp images # --------------------------------------------- # Set Vary:Accept header if we came here by way of our redirect, which set the ADDVARY environment variable # The purpose is to make proxies and CDNs aware that the response varies with the Accept header <IfModule mod_headers.c> <IfModule mod_setenvif.c> # Apache appends "REDIRECT_" in front of the environment variables defined in mod_rewrite, but LiteSpeed does not # So, the next lines are for Apache, in order to set environment variables without "REDIRECT_" SetEnvIf REDIRECT_EXISTING 1 EXISTING=1 SetEnvIf REDIRECT_ADDVARY 1 ADDVARY=1 Header append "Vary" "Accept" env=ADDVARY # Set X-WPO-WebP header for diagnose purposes Header set "X-WPO-WebP" "Redirected directly to existing webp" env=EXISTING </IfModule> </IfModule> # END WP-Optimize WebP Rules # BEGIN ShortPixelWebp # The directives (lines) between "BEGIN ShortPixelWebp" and "END ShortPixelWebp" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. # END ShortPixelWebp