For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Ankur_5273's avatar
Ankur_5273
Icon for Nimbostratus rankNimbostratus
Aug 11, 2014

Convert HTTP Redirect to case sensitive

Hi Experts,

Kindly help in converting the below highlighted part in case sensitive format

when HTTP_REQUEST {

if { [HTTP::host] ne "www.myweb.com" } {

return

}

switch -glob [HTTP::path] {

"/secureapp/connect/REPORT_en/REP/*" {

  **HTTP::redirect "**http://www.myweb.com[string map {/secureapp/connect/REPORT_en/REP/ /en/} [HTTP::uri]]"****
}

"/en/*" {
  **HTTP::uri [string map {/en/ /secureapp/connect/REPORT_en/REP/} [HTTP::uri]]**
}
default {

   do nothing
}

}

}

Regards,

Ankur

5 Replies

  • The iRule as you have it is already case sensitive. Do you want the case sensitivity removed from it?

     

  • Hi Cory

     

    The application owner has mentioned that "REPORT" in the below string map can be either in small or caps and if it is typed in small , access is not working . Hence , is case sensitive configuration applicable to string map OR URI as well (as per the above iRule) ?

     

    http://www.myweb.com[string map {/secureapp/connect/REPORT_en/REP/ /en/} [HTTP::uri]]

     

    Regards,

     

    Ankur

     

  • I would just convert the HTTP::path check to lowercase and then match against that, like this:

    switch -glob [string tolower [HTTP::path]] {
     "/secureapp/connect/report_en/rep/*" {
      **HTTP::redirect "**http://www.myweb.com[string map {/secureapp/connect/REPORT_en/REP/ /en/} [HTTP::uri]]"****
    }
    
  • Hi Cory

    Can you help in letting me know how to remove case sensitivity for below part of the iRule so that REPORT word in the string map can either be small or caps ?

    switch -glob [HTTP::path] {

    "/secureapp/connect/REPORT_en/REP/*" {
      HTTP::redirect "http://www.myweb.com[string map {/secureapp/connect/REPORT_en/REP/ /en/} [HTTP::uri]]"
    }
    "/en/*" {
      HTTP::uri [string map {/en/ /secureapp/connect/REPORT_en/REP/} [HTTP::uri]]
    }
    default {
       do nothing
    }
    

    }

  • The code snippet I posted above should work. Your check against lower case 'report' is what was failing. By first converting the string to lowercase and then matching against that, you'll ensure case sensitivity isn't an issue. So here's your whole iRule:

     

    when HTTP_REQUEST {
    
     if { [HTTP::host] ne "www.myweb.com" } {
      return
     }
    
     switch -glob [string tolower [HTTP::path]] {
      "/secureapp/connect/report_en/rep/*" {
        **HTTP::redirect "**http://www.myweb.com[string map {/secureapp/connect/REPORT_en/REP/ /en/} [HTTP::uri]]"****
      }
      "/en/*" {
        **HTTP::uri [string map {/en/ /secureapp/connect/REPORT_en/REP/} [HTTP::uri]]**
      }
      default {
       do nothing
      }
     }
    }