Forum Discussion

U_franco_117956's avatar
U_franco_117956
Icon for Nimbostratus rankNimbostratus
Apr 10, 2014

Web redirections with data group fail if URI contains "?"

text
Hi Guys.

I have imported a huge preformated txt file of redirections in order to be managed in a data-group and be used in an irule applied to our vserver.

All seems to work fine and redirections are being managed in a right way. However I´m noticing this kind of redirections in the original txt file are being managed fine:

"/wines/mostsold/themostsold.asp" := "www.ourshop.com/shop/gourmetshop/",

But redirections with "?" character contained in the URI are not being managed like this one:

"/wines/product/product.asp?pRef=13345204286" := "www.ourshop.com/shop/gourmetshop/browse/productDetailCult.jsp?productId=A10111941",

This is the irule applied to our vserver:

when HTTP_REQUEST {
    if {[TCP::local_port] == 443} {
        set protocol "https"
    } else {
        set protocol "http"
    }

    set newuri [class match -value [string tolower [HTTP::uri]] equals redirections_gourmet301]
        log local0. "URI IS: $newuri"
    if {$newuri ne ""} {
        HTTP::respond 301 noserver Location "$protocol://$newuri"
        unset newuri
    } else {
               log local0. "URI IS NOT FOUND ON DATAGROUP"
        }
}

It seems URI is not found on datagroup when URI contains "?" character. This kind of redirections managed in a irule containing IF URI equals...THEN redirect... sentences are managed fine, but i don´t know why they are not working fine in a datagroup.

Anybody coul tell my what is happening? Am i doing something wrong??

Thanks.

  • From your original post, I see that you are using upper case letters in your data group. When you are attempting to match a lower case HTTP::uri against it, it'll never match. Change your data group entries to use all lower case letters and see if that makes a difference for you.

     

  • Though it may be more process intensive, you could change the 'equals' in your iRule to 'contains'. This way it will match a portion of the URI string and not the entire thing verbatim. This sounds like it may solve your problem.

     

    • U_franco_117956's avatar
      U_franco_117956
      Icon for Nimbostratus rankNimbostratus
      Thanks for your answer Cory. However your suggestion doesn´t solve my problem. Still url´s containing "?" characters are no managed in the right way. Thanks.
  • From your original post, I see that you are using upper case letters in your data group. When you are attempting to match a lower case HTTP::uri against it, it'll never match. Change your data group entries to use all lower case letters and see if that makes a difference for you.

     

    • U_franco_117956's avatar
      U_franco_117956
      Icon for Nimbostratus rankNimbostratus
      Eurekaaaaa!!! Cory, you are right. The blame was on upper/lower case characters, not in "?" character. I hate to made here stupid questions, but I promise you I was blocked and I wasn´t able to find the root cause of my issue. Thank you very much.
    • Cory_50405's avatar
      Cory_50405
      Icon for Noctilucent rankNoctilucent
      There are no stupid questions. Glad to hear it's working now.