Forum Discussion

smiley_dba_1116's avatar
smiley_dba_1116
Icon for Nimbostratus rankNimbostratus
Jul 13, 2015

The Dreaded %20 for space

Does anyone have a idea how to create a iRule that takes into account spaces between words? I have the iRule below and when I enter abc.def.com/en-ca/Teams/Performance Improvement/0700Reports/default.aspx, the browser adds a %20. Example: http://abc.def.com/en-ca/Teams/Performance%20Improvement/0700Reports/default.aspx

when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] contains "abc.def.com") and [HTTP::uri] starts_with "/en-ca/Teams/IT/IM/default.aspx" } {
                HTTP::redirect "http://def.ghi.com/IM2/default.aspx" 
  }
elseif { ([string tolower [HTTP::host]] contains "abc.def.com") and [HTTP::uri] starts_with "/en-ca/Teams/Performance Improvement/0700Reports/default.aspx" } {
                HTTP::redirect "http://def.ghi.com/PerformanceMeasures/0700Reports/default.aspx" 
  }
  }

Thoughts?

RGW

  • Would I need to modify this to be a HTTP_RESPONSE? And if so, would I need to modify the code?

     

  • Hi,

    What about decode uri?

    See if it helps you:
    when HTTP_REQUEST {
        log local0. "Host: [HTTP::host] | URI: [HTTP::uri] | DECODE: [URI::decode [HTTP::uri]]"
    
        if { [string tolower [HTTP::host]] contains "abc.def.com" } {
            switch -glob [URI::decode [HTTP::uri]] {
                "/en-ca/Teams/IT/IM/default.aspx*" {
                    HTTP::redirect "http://def.ghi.com/IM2/default.aspx"
                }
                "/en-ca/Teams/Performance Improvement/0700Reports/default.aspx*" {
                    HTTP::redirect "http://def.ghi.com/PerformanceMeasures/0700Reports/default.aspx"
                }
            }
        }
    }
    

    Regards.