Enable RewriteLog

AndreyPopov

Well-Known Member
#21
Yes, but the rule of this topic is the first rule.
after this:

Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$1$2$3.webp [L]
next rules
Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$1$2$3$4.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$1$2$3$4$5.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]
not executed

this rule
Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^img/(.*).png$ %{ENV:REWRITEBASE}imgwebp/$1.webp [L]
before or after "$1$2$3.webp [L]"?
 

LuigiMdg

Active Member
#22
Your comment about @AndreyPopov in other post. :) So I use your comment because I feel like I'm talking to a wall. ;)
In my opinion, however, you did not understand the question well .. You have to rewrite only the .png images towards the .webp, you said to change the .jpg to .png but this would only ruin all the rewrites that now work on the. site, i.e. for PrestaShop product and category images.
In those rewrites, if you look carefully, you will see that the files must necessarily start with a number or with the c (for categories).
In summary, your solution isn't a solution, so I'm afraid the wall is you, not me.
 

serpent_driver

Well-Known Member
#26
In my opinion, however, you did not understand the question well .. You have to rewrite only the .png images towards the .webp, you said to change the .jpg to .png but this would only ruin all the rewrites that now work on the. site, i.e. for PrestaShop product and category images.
In those rewrites, if you look carefully, you will see that the files must necessarily start with a number or with the c (for categories).
In summary, your solution isn't a solution, so I'm afraid the wall is you, not me.
Hey colleague, now I know what you want after you posted the almost complete code about image rewriting. How can we help you if you don't even tell us what software it is? If you have to pull everything out of your nose, nothing can come of it.
 

serpent_driver

Well-Known Member
#28
@AndreyPopov

This will also not work. It needs a unique Rewrite Condition to not to conflict with the current image rewriting method. In my mind the current image rewriting rules should only be extended from:

Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$1$2$3$4.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$1$2$3$4$5.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]
to

Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.(jpg|png)$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$1$2$3$4.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.(jpg|png}$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$1$2$3$4$5.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.(jpg|png}$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]
but all .webp mages seem to be in different image directories.
 
Last edited:

AndreyPopov

Well-Known Member
#29
if I understand
ipg images are product named in category named folders and that's why required more complex rules.

png images are few with simple names in one folder and no need this
^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.
 

serpent_driver

Well-Known Member
#30
No, it is completely different. PrestaShop generates a huuuuuge number of different images and stores them in a huuuuge number of different directories. A png image makes no difference to jpg images, but it seems PrestaShops priorize jpeg's and that's why there is no rewrite rule for png to webp. If @LuigiMdg would store .png images like .jpegs the solution would be simple and can be done like I posted before, extending the current rewrite rules with png images and this should work.
 

AndreyPopov

Well-Known Member
#31
in my opinion rewrite block for webp must be seen like:

Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond {detect that image png}
RewriteRule ^img/(.+)\.png$  %{ENV:REWRITEBASE}imgwebp/$1.webp
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond {detect non-png image}
RewriteCond {detect one folder level}
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$1$2$3.webp
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond {detect non-png image}
RewriteCond {detect two folder level}
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$1$2$3$4.webp
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond {detect non-png image}
RewriteCond {detect three folder level}
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$1$2$3$4$5.webp
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond {detect non-png image}
RewriteCond {detect four folder level}
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp
without [L] flags
 

AndreyPopov

Well-Known Member
#32
may be exist way(syntax) in img/path/filename.ext replace img to imgweb and add .webp at the end?

img/path/filename.ext -> imgwebp/path/filename.ext.webp
 

LuigiMdg

Active Member
#33
Hey colleague, now I know what you want after you posted the almost complete code about image rewriting. How can we help you if you don't even tell us what software it is? If you have to pull everything out of your nose, nothing can come of it.
It doesn't change much if the rule I'm going to insert is the first on the list, don't you think ..?
I mean
Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^img/(.+)\.png$  %{ENV:REWRITEBASE}imgwebp/$1.webp
Not work
@AndreyPopov

This will also not work. It needs a unique Rewrite Condition to not to conflict with the current image rewriting method. In my mind the current image rewriting rules should only be extended from:

Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$1$2$3$4.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$1$2$3$4$5.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]
to

Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.(jpg|png)$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$1$2$3$4.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.(jpg|png}$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$1$2$3$4$5.webp [L]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.(jpg|png}$ %{ENV:REWRITEBASE}imgwebp/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]
but all .webp mages seem to be in different image directories.
Why do you focus on these rules, which have nothing to do with the necessary rule?
if I understand
ipg images are product named in category named folders and that's why required more complex rules.

png images are few with simple names in one folder and no need this
^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.
Exactly, the PNGs are in the root of the img folder, while the WEBPs are in the imgwebp folder.
may be exist way(syntax) in img/path/filename.ext replace img to imgweb and add .webp at the end?

img/path/filename.ext -> imgwebp/path/filename.ext.webp
Yes, but without path (subfolders), just images in root folder.
 

AndreyPopov

Well-Known Member
#34
who make webp from jpg/png?
may be move webp images from imgwebp folder to img?
and use "standard" rewrite rule: if webp add .webp extension to filename?

I see many examples that do like this.
Journal3 theme for Opencart convert by itself algorithm jpg/png images in same folders and only add .webp to original file name.
 

LuigiMdg

Active Member
#35
who make webp from jpg/png?
may be move webp images from imgwebp folder to img?
and use "standard" rewrite rule: if webp add .webp extension to filename?

I see many examples that do like this.
Journal3 theme for Opencart convert by itself algorithm jpg/png images in same folders and only add .webp to original file name.
I don't understand why you keep proposing alternative solutions, when a simple rewrite rule should suffice.
Can we go back to the main topic?
Is there any way to trace the path where it looks for the server based on the rewrite rules?
 

AndreyPopov

Well-Known Member
#36
I don't understand why you keep proposing alternative solutions, when a simple rewrite rule should suffice.
Can we go back to the main topic?
you try find a way:
- why not work your rule for png -> webp
- and want see rewrite path in RewriteLog

right?

for Apache I find:
https://httpd.apache.org/docs/current/mod/mod_rewrite.html
Code:
LogLevel alert rewrite:trace3
and:
RewriteLog
Those familiar with earlier versions of mod_rewrite will no doubt be looking for the RewriteLog and RewriteLogLevel directives. This functionality has been completely replaced by the new per-module logging configuration mentioned above.
LSWS may be use same variables?
may be try add to .htaccess
Code:
LogLevel alert rewrite:trace8
sorry
https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:rewrite-logs
New Apache 2.4 rewrite log directive “LogLevel alert rewrite:trace3” is not yet supported by LiteSpeed, hence you can use the above rewrite log directive “RewriteLogLevel 2” to enable rewrite log for LiteSpeed even you run apache 2.4.


------------------------------------------

/usr/local/lsws/conf/vhosts/domain-name/vhost.conf

Inserting RewriteLogLevel 9 between the IfModule LiteSpeed tags and restarting LiteSpeed, as indicated in this article:
I think
for vhost.conf you must add RewriteLogLevel 9 without IfModule LiteSpeed tags?

with IfModule LiteSpeed tags for .htaccess file.
 
Last edited:

LuigiMdg

Active Member
#37
you try find a way:
- why not work your rule for png -> webp
- and want see rewrite path in RewriteLog

right?

for Apache I find:
https://httpd.apache.org/docs/current/mod/mod_rewrite.html
Code:
LogLevel alert rewrite:trace3
and:


LSWS may be use same variables?
may be try add to .htaccess
Code:
LogLevel alert rewrite:trace8
sorry
https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:rewrite-logs




------------------------------------------



I think
for vhost.conf you must add RewriteLogLevel 9 without IfModule LiteSpeed tags?

with IfModule LiteSpeed tags for .htaccess file.
https://docs.litespeedtech.com/lsws/cp/cpanel/rewrite-logs/
It is evident that you have not even opened the link shared in the first post.. The article clearly states that that function is not available on LiteSpeed.
I appreciate the commitment but I don't want to waste any more time.. I'll try to open a ticket, even if my old experiences don't give me hope.
 

AndreyPopov

Well-Known Member
#38
https://docs.litespeedtech.com/lsws/cp/cpanel/rewrite-logs/
It is evident that you have not even opened the link shared in the first post..
in link that you post absent words about "IfModule LiteSpeed tags"

Open the relevent config file and add the RewriteLogLevel directive followed by a number for how detailed you want

if I undestanding:
Code:
<IfModule LiteSpeed>
RewriteLogLevel 9
</IfModule>
must be used in .htaccess file

for
/usr/local/lsws/conf/vhosts/domain-name/vhost.conf you must add only "RewriteLogLevel 9"



for example OLS Configuration Examples – OpenLiteSpeed
Virtual Host Configuration Files
Code:
rewrite {
enable 1
autoLoadHtaccess 1
logLevel 9
}
 
Last edited:
Top