Forum Discussion
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
- Cory_50405
Noctilucent
The iRule as you have it is already case sensitive. Do you want the case sensitivity removed from it?
- Ankur_5273
Nimbostratus
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
- Cory_50405
Noctilucent
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]]"**** } - Ankur_5273
Nimbostratus
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 }}
- Cory_50405
Noctilucent
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 } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com