Forum Discussion

Ranvir_Floura_7's avatar
Ranvir_Floura_7
Icon for Nimbostratus rankNimbostratus
Jan 02, 2008

iRule and trailing slash issue

Folks,

 

 

Got a issue that is bugging me. Here is the iRule that I am working off and it works for the most part, but i have to put the trailing "/" for it to work. I need to have it working without the slash at the end.

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] starts_with "/dev3" } {

 

HTTP::uri [string range [HTTP::uri] 5 end]

 

pool dev3

 

}

 

}

 

 

The dev3 entry is mostly working as long as you remember to include a trailing "/" on the URL -- so https://www.aaa.bbb.com/dev3/ works where https://www.aaa.bbb.com/dev3 does not, it gives a message about a bad request.

 

 

Any ideas?

 

 

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    With that rule, if the URI was just /dev3, the URI sent to the web app would be null. That's not valid in HTTP. You could use this to check the URI:

    
    when HTTP_REQUEST {
       if { [string tolower [HTTP::uri]] starts_with "/dev3" } {
           Set the pool to dev3 for all requests starting with /dev3
          pool dev3
           Remove /dev3 from the URI
          set uri [string range [HTTP::uri] 5 end]
           Check if updated URI has a length
          if {$uri}{
              Updated URI has a length, so set the request to the updated URI
             HTTP::uri $uri
          } else {
              Updated URI was empty, so set the URI to /
             HTTP::uri /
          }
       }
    }

    Aaron