Forum Discussion

doc_hack_12696's avatar
doc_hack_12696
Icon for Nimbostratus rankNimbostratus
Nov 29, 2010

Re-write works with one URI but the other

when HTTP_REQUEST {

 

switch -glob [HTTP::uri] {

 

"/a22/O/cd/wd" {

 

set xyz [HTTP::header "abc"]

 

HTTP::uri [string map "/a22/O /a22/$abc" [HTTP::uri]]

 

pool p_rewrite }

 

"/v1_0/O/cd" {

 

set xyz [HTTP::header "abc"]

 

HTTP::uri [string map "/a22/O /a22/$abc" [HTTP::uri]]

 

pool p_rewrite }

 

default {

 

pool p_nonrewrite }

 

}

 

}

 

 

The second one (/a22/O/cd) works as expected and the user is routed to the correct Pool. In the first case (/a22/O/cd/wd) it does not work. Note that the Pool (p_rewrite) is the same in both cases.

3 Replies

  • Small correction - in the second statement the uri begins with /a22 not /v1_0 as previously posted

     

     

    when HTTP_REQUEST {

     

    switch -glob [HTTP::uri] {

     

    "/a22/O/cd/wd" {

     

    set xyz [HTTP::header "abc"]

     

    HTTP::uri [string map "/a22/O /a22/$abc" [HTTP::uri]]

     

    pool p_rewrite }

     

    "/a22/O/cd" {

     

    set xyz [HTTP::header "abc"]

     

    HTTP::uri [string map "/a22/O /a22/$abc" [HTTP::uri]]

     

    pool p_rewrite }

     

    default {

     

    pool p_nonrewrite }

     

    }

     

    }

     

     

    The second one (/a22/O/cd) works as expected and the user is routed to the correct Pool. In the first case (/a22/O/cd/wd) it does not work. Note that the Pool (p_rewrite) is the same in both cases.
  • Hi dochack,

    Can you add logging to the iRule and retest? Also, I assume you're rewriting the URI with the value of the abc header saved to a variable named $abc?

    
    when HTTP_REQUEST {
       log local0. "original URI: [HTTP::uri]"
       switch -glob [HTTP::uri] {
          "/a22/O/cd/wd" {
             set xyz [HTTP::header "abc"]
             HTTP::uri [string map "/a22/O /a22/$xyz" [HTTP::uri]]
             pool p_rewrite
             log local0. "Matched case 1"
          }
          "/a22/O/cd" {
             set abc [HTTP::header "abc"]
             HTTP::uri [string map "/a22/O /a22/$abc" [HTTP::uri]]
             pool p_rewrite
             log local0. "Matched case 2"
          }
          default {
             pool p_nonrewrite
             log local0. "Default case"
          }
       }
    }
    when HTTP_REQUEST priority 501 {
       log local0. "Current URI: [HTTP::uri]"
    }
    

    Aaron
  • Figured out what the problem was - missing a * on the first statement. Should have been "/a22/O/cd/wd*"