Change file extension

#1
I refer to image substitution with a webp image.
LightSpeed cache appends webp to image file name when it serves webp images.
For example a file xyz.png is replaced with the file xyz.png.webp
The current rules in the htaccess files are -

### marker WEBP start ###
RewriteCond %{HTTP_ACCEPT} "image/webp" [or]
RewriteCond %{HTTP_USER_AGENT} "Page Speed"
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
RewriteCond %1 >13
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
### marker WEBP end ###


Can you please provide the htaccess rules to simply change the extension of image files to webp. In the above given example the name of the image file
will become xyz.webp (as opposed to xyz.png.webp.

Many Thanks for your help
 

serpent_driver

Well-Known Member
#3
@Menashay

1.) You have cache plugin for Wordpress. This forum doesn't support this plugin any longer. Read this to get more information about how and where to get support for this plugin: https://www.litespeedtech.com/support/forum/threads/please-use-the-official-wordpress-forum.16028/

2.) Replace the current code:

Code:
### marker WEBP start ###
RewriteCond %{HTTP_ACCEPT} "image/webp" [or]
RewriteCond %{HTTP_USER_AGENT} "Page Speed"
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
RewriteCond %1 >13
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
### marker WEBP end ###
with

Code:
### marker WEBP start ###
RewriteCond %{HTTP_ACCEPT} "image/webp" [or]
RewriteCond %{HTTP_USER_AGENT} "Chrome-Lighthouse"
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
RewriteCond %1 >13
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
### marker WEBP end ###
The current code contains an outdated UA for Google Pagespeed, but will be fixed in upcoming version (v4.7-rc3).

3.) The way cache plugin replaces file extension to serve webp images is a common method, but replacing file extension will only be done if a browser sends request header for Accept: image/webp. If there is no such value, file extension is untouched. If you want to use webp images you must also use LiteSpeed image transformation service. If you don't use this service it makes no sense to enable webp image feature.
 
Last edited:
Top