redirect rule is not wokring

#1
Hi,

in apache I have the below conf which proxy the server example domain.com/webmail to access mail on localhost
but in litespeed, is not working I need to add / at the end like domain.com/webmail/
I have written conf to redirect to domain.com/webmail to domain.com/webmail/ but the below conf is not working it will not redirect
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/webmail
RewriteRule ^(webmail)$ /$1/ [R=301,L]
ProxyPass "/webmail/" "http://127.0.0.1:2002/mail"
ProxyPassReverse "/webmail/" "http://127.0.0.1:2002/mail"
above conf, I have added in server conf and I am using Apache conf in litespeed

but this same rule is working in htaccess it will redirect properly
RewriteRule ^(webmail)$ /$1/ [R=301,L]
 
#3
Hi,

I have followed the above guide but my proxy to http://127.0.0.1:2002/mail on port
below conf I have used but is not work its only redirects the domain.com/webmail to domain.com/webmail/

RewriteRule ^/webmail /$1/ [R=301]
RewriteRule /webmail/(.*) http://127.0.0.1:2002/mail/$1 [P]
RewriteRule ^/webmail /$1/ [R=301]
ProxyPass "/webmail" "http://127.0.0.1:2002/mail"
ProxyPassReverse "/webmail" "http://127.0.0.1:2002/mail"

The above conf is working when I hit URL like domain.com/webmail/
but when I hit domain.com/webmail then is not work it will redirect to 127.0.0.1:2002/mail


I am using litespeed with Apache configuration in this pass proxy, not support?
 
Last edited:
#4
Hi,
I have solved the above issue but now

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/test(.*)
RewriteRule ^(.*)$ https://%{HTTP_HOST}:2003%{REQUEST_URI} [R=301,L]
</IfModule>
this conf is not working?
 

serpent_driver

Well-Known Member
#7
it shows 404 not found but it should be redirected to domain.com:2003
Then, remove %{REQUEST_URI} after port number if you only want to redirect to HTTP_HOST.

Or do it very simply.

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/test
RewriteRule ^(.*)$ https://www.domain.com:2003 [R=301,L]
</IfModule>
 

serpent_driver

Well-Known Member
#9
Try this:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/test [NC]
RewriteRule ^(.*)$ https://www.domain.com:2003 [R=301,L]
</IfModule>
Make sure that you have to empty the browser cache with every new attempt. A browser remembers a redirection even when it is wrong.
 
#10
Yes, I have emptied the browser cache and tested in incognito but it did not work.
below is my Apache conf which worked in Apache but not working in litespeed

<Location /test>
Redirect "https://%{HTTP_HOST}:2003%{env:MATCH_PATH}"
</Location>
apache conf which works in Apache
 

serpent_driver

Well-Known Member
#11
There's really no reason why the rewrite rule shouldn't work with LiteSpeed, since LiteSpeed is almost fully Apache compatible. However, the emphasis is on "almost". This is especially true when using envelopes. However, I am not aware of any limitations of conventional rewrite rules that are used for redirection. If all attempts so far have failed, please contact LiteSpeed Support directly: support@litespeedtech.com
 
Top