htaccess apache to litespeed (mb some syntax problem)

Discussion in 'Apache Migration/Compatibility' started by baqpji9, Aug 26, 2018.

Tags:
  1. baqpji9

    baqpji9 New Member

    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: Aug 27, 2018
  2. mistwang

    mistwang LiteSpeed Staff

    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: Aug 27, 2018
  3. baqpji9

    baqpji9 New Member

    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: Aug 26, 2018
  4. NiteWave

    NiteWave Administrator

    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. baqpji9

    baqpji9 New Member

    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?
     
  6. baqpji9

    baqpji9 New Member

    Won't anyone help with it?
     
  7. NiteWave

    NiteWave Administrator

    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.
     

Share This Page