Enable RewriteLog

LuigiMdg

Active Member
#1
Hello everyone,
I'm trying to activate the RewriteLog, I added the directive in the file:
/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:
https://docs.litespeedtech.com/lsws/cp/cpanel/rewrite-logs/

However I don't find anything in the LiteSpeed log, maybe it is saved elsewhere?
Could someone enlighten me?
 

LuigiMdg

Active Member
#3
it should work, and the logs are in error log. do you have any control panel installed ?

alternatively, you can refer
https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:toggle-debug-logging
you'll see the rewrite logs also included in the debug logs ( file still be error log)
I've CyberPanel.

The only error I keep getting is this:
Code:
[85576] [T0] [APVH_website.url: 443: REWRITE] Detects bad proxy action without updating target URL. Ignore. while parsing: RewriteRule. * - [P]
But I don't enter P as a rewrite method, this is the rule I entered:
Code:
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^img/(.*).png$ %{ENV:REWRITEBASE}imgwebp/$1.webp [L]
 
Last edited:

LuigiMdg

Active Member
#5
I've done some testing and that error is not related to this .htaccess line.
Activating the log does not give any error when I activate this rule, but the images are not seen.
I remember once I could see which url goes to open the rewrite, but maybe I get confused with Lighttpd.

PS: I've LiteSpeed Enterprise
 

serpent_driver

Well-Known Member
#7
@LuigiMdg

Why do you expect any error? To proof if your rule works you only have to set different request accept header. The one with Accept/webp and the other one without. But indepently from this, LSWS is very tolerant related to wrong .htaccess rules.

Depending on your HTML code turn the direction what should be rewritten.

Code:
RewriteCond %{HTTP_ACCEPT} !image/webp [NC]
RewriteRule ^(.*)\.webp /$1.png [R=301,L]
 

LuigiMdg

Active Member
#9
@LuigiMdg

Why do you expect any error? To proof if your rule works you only have to set different request accept header. The one with Accept/webp and the other one without. But indepently from this, LSWS is very tolerant related to wrong .htaccess rules.

Depending on your HTML code turn the direction what should be rewritten.

Code:
RewriteCond %{HTTP_ACCEPT} !image/webp [NC]
RewriteRule ^(.*)\.webp /$1.png [R=301,L]
Because the images are not seen, so redirect to the wrong place.
 

serpent_driver

Well-Known Member
#10
Because the images are not seen, so redirect to the wrong place.
If there is a redirection, then redirection works and if it works, then there is no error. If only redirect location is wrong, then either your rule must be wrong or request header for Accept contains values that causes the redirection. Why don't you do what I suggested?
 

LuigiMdg

Active Member
#12
If there is a redirection, then redirection works and if it works, then there is no error. If only redirect location is wrong, then either your rule must be wrong or request header for Accept contains values that causes the redirection. Why don't you do what I suggested?
Because it seemed to me I did not understand the problem .. In fact it seems to me that your rule is for .webp images that are not found and which would then be redirected to the jpg .. Am I wrong?

exist another rewrite rule for jpg? with [L} flag?
Yes, this is other rewrite rules:
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]
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]
 

serpent_driver

Well-Known Member
#13
@LuigiMdg

Sorry, I should have explained my rule . It works different as yours and isn't applicable for your case, because you have different directory name for each kind of image type, so forget it. But what I meant it was to test your rule with different accept headers. curl is your friend! :)
 

serpent_driver

Well-Known Member
#14
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]
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]
You already have what you need. Copy & Paste your code and replace .jpg with .png. That's it.
 

LuigiMdg

Active Member
#16
You already have what you need. Copy & Paste your code and replace .jpg with .png. That's it.
No, that's not it.. Those rules are for images that necessarily start with 1 number, ie the products, they work great and must remain as they are.
[L] flag
L (last - stop processing rules)
Last rule: instructs the server to stop rewriting after the preceding directive is processed.
I do not know what you're talking about.
 
Top