I am trying to show webp pictures on my website where there is a jpeg or png picture using LiteSpeed Web Server and an htaccess file.
The snippet is not working because of the name of my webp pictures. Instead of changing the extension, my converter added the new extension to the full name of the picture. Example:
URL of normal pics:
http://domain.tld/path/to/pic/image.png (or jpe?g)
URL of webp pics:
http://domain.tld/path/to/pic/image.png.webp
This is how my htaccess looks:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} (.*)(\.(jpe?g|png))$
RewriteRule .* %1\.webp [L,T=image/webp]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp
I think the problem is in the RewriteRule. The result I am getting is:
http://domain.tld/path/to/pic/image.webp
Instead of:
http://domain.tld/path/to/pic/image.png.webp (or jpe?g.webp)
I tried changing the RewriteRule line to this but it didn't work:
RewriteRule .* %1\.(jpe?g|png).webp [L,T=image/webp]
Can somebody shed some light into this? I am a beginner on htaccess and I know I am not using the correct syntax on this to make it work. This is the website in case you guys want to inspect the page and check the images: LEXSTYLE Any help would be really appreciated. Thanks.