htaccess apache to litespeed (mb some syntax problem)

#1
Hello, got a such problem, some clients come on a wrong link cause of converted special symbols:
they got /%23search instead of /#search (anchor link)

So in apache should work well this phrase:
Code:
RewriteRule ^(.*)?%23(.*)?$ $1#$2 [NE,R=301,L,B]
On my shared hosting with litespeed it doesn't work. Moreover I tried to add "/" after "^" as it said in some guides but with no any changes.
So my last try was:
Code:
RewriteRule ^/(.*)?%23(.*)?$ $1#$2 [NE,R=301,L,B]
Maybe anyone can help me with this - much interested what syntax does litespeed not understand or what do I do wrong.
I've tried more obvious:
Code:
RewriteRule ^/%23search/ /#search/ [NE,R=301,L,B]
and
Code:
#RewriteRule ^/%23search/ http://mydomain.lol/#search/ [NE,R=301,L,B]
No any works for me...
 
Last edited by a moderator:

mistwang

LiteSpeed Staff
#2
What is the input URL, what is the expected output?
Code:
RewriteRule ^(.*)?%23(.*)?$ $1#$2 [NE,R=301,L,B]
Looks it is trying to match the query string part of the URL with the RewriteRule. I do not know how it could work with Apache, as query string can only be accessed through %{QUERY_STRING} via RewriteCond .
 
Last edited by a moderator:
#3
What is the input URL, what is the expected output?
mywebsite.com/%23search - is the input url
mywebsite.com/#search - is needed one
I'm not sure what for do I need to use conditions here if there are no "special situation", moreover I use only $ for groups.
As I understand query_string is needed only after ?
 
Last edited:

NiteWave

Administrator
#4
RewriteRule ^(.*)?%23(.*)?$ $1#$2 [NE,R=301,L,B]
by my tests on apache 2.4, this rule not work either.
the test page can be as simple as
Code:
#cat test.html
<a href="%23search"> dest #search </a>
while works well with
Code:
#cat test.html
<a href="#search"> dest #search </a>
Plus: no rewrite rule needed in this case.

and in both cases, litespeed behaves exactly same as apache.
 
#5
To be true wanted to make the rule for all mistakes of this encoding of # to %23
Strange that it's not workin on apache, I didn't try myself, but the guy with the same problem assured, that he got the result with this phrase...
So what is the real difference in apache and litespeed, only "/" after "^"? Other should work the same on both?
And so can you help me with understanding what is wrong with my regular phrase so?
 

NiteWave

Administrator
#7
Strange that it's not workin on apache, I didn't try myself, but the guy with the same problem assured
please try yourself. or ask the guy to try the simple example. if you or he can try out on apache, let us know. I'll try to reproduce the issue on our server, switch between litespeed and apache. yes, you only need test on apache, work out a working example which is basic enough like the example I gave.
 
Top