My customer is using Litespeed with CPanel v106.0.10. I have a RewriteRule like this in .htaccess file:
RewriteCond %{HTTP_HOST} ^www.site.com$
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}%{ENV:REWRITEBASE}/img/$1.webp -s
RewriteRule ^img/([_a-zA-Z0-9-]+)\.jpg$ %{ENV:REWRITEBASE}img/$1.webp [B,L]
RewriteCond %{HTTP_HOST} ^www.site.com$
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}%{ENV:REWRITEBASE}/img/$1.webp !-s
RewriteRule ^img/([_a-zA-Z0-9-]+)\.jpg$ %{ENV:REWRITEBASE}webp.php?src=img/$1.jpg [B,L]
The goal is to serve images into WEBP format when the WEBP file exists, if not then call the PHP script to compress the JPG file into WEBP format. It's working good with Apache but when using Litespeed server I get a 403 error when the WEBP file does not exists. Also when the URL of the image does not match the real file name (URL rewriting) then it also works. So I think there is something that blocks URL rewriting when the URL match with a real file. Who can help?