Forum Discussion

Todd_Jones_1074's avatar
Todd_Jones_1074
Icon for Nimbostratus rankNimbostratus
Sep 18, 2012

HTTP::redirect cause reset

Hello,

 

I've been given a requirement to ensure that a URI is passed to the web servers with the correct case. For example:

 

www.host.com/CASEmatters is correct

 

www.host.com/casematter or /CaSeMaTtErS need to be redirected to /CASEmatters.

 

I've tried HTTP::redirect, HTTP::uri and HTTP::respond. All of them result in a reset instead of a redirect.

 

Here is my iRule with the redirect. Any help you can provide will be appreciated.

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::uri]] {

 

"/foo*" { pool foo }

 

"/bar*" { pool bar }

 

"/casematters*" {

 

switch -glob [HTTP::uri] {

 

Check URI for match to desired case "CASEmatters"

 

"/CASEmatters*" { pool casematters }

 

If it doesn't match then redirect

 

default { HTTP::redirect "https://[HTTP::host]/CASEmatters" }

 

}

 

}

 

default { pool default }

 

}

 

}

 

 

5 Replies

  • I'd skip the nested switch evaluation and just trigger the casematters code if the [string tower [HTTP::uri] equals "/casematters". Also, assuming you don't need the client to actually see the different case in the address bar, just change the HTTP::uri on ingress.

     

     

    
    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            "/foo*" {
    log local0. "foo pool"
    pool foo
    }
            "/bar*" { 
    log local0. "bar pool"
    pool bar 
    }
            "/casematters*" {
    log local0. "casematters pool"
                    pool casematters
    set sub_uri [findstr [string tolower [HTTP::uri]] "/casematters" 12]
    log local0. "sub_uri = $sub_uri"
                    HTTP::uri "/CASEmatters$sub_uri"
            }
            default { pool default }
        }
    }
    

     

  • No runtime error in the logs.

     

     

    @Kevin Stewart - your suggestion worked! Thank you. I'm still curious why the reset but now my client will be happy :-)