Forum Discussion
Joe_Pipitone
Nimbostratus
Nov 12, 2009Case insensitive redirects not quite working
I have an iRule that is supposed to do simple redirection if someone types in the following:
http://www.ourdomain.org/LV2010 or http://www.ourdomain.com/lv2010
It seems as though I haven't quite been able to get this to work if I attempt to add anything further past the /LV2010 such as /LV2010/instructors
Can anyone tell me what may be causing this to happen? Here are what the syntax looks like:
if { [string tolower [HTTP::uri]] starts_with "/lv2010" } {
HTTP::redirect "http://www.ourdomain.org/education/display.aspx"
} (THIS WORKS)
if { [string tolower [HTTP::uri]] starts_with "/lv2010/instructors*" } {
HTTP::redirect "http://subdomain.ourdomain.org/events/some-other-file-here-2010/speakers/speaker-list.aspx"
} (THIS DOES NOT WORK)
Any ideas? These need to be case insensitive as well
9 Replies
Sort By
- Joe_Pipitone
Nimbostratus
Also, if I have a rule such as:if { [string tolower [HTTP::uri]] starts_with "/lv2010/es*" } { HTTP::redirect "http://www.ourdomain.org/education/display.aspx?id=8230" }
if { [string tolower [HTTP::uri]] starts_with "/lv2010/es/qualify" } { HTTP::redirect "http://subdomain.ourdomain.org/events/some-other-file-here-2010/information/qualification.aspx" }
- Colin_Walker_12Historic F5 AccountWhen using the starts_with command you don't need to add an asterisk. It's not a glob style match, the asterisk is implied.
if { [string tolower [HTTP::uri]] starts_with "/lv2010/instructors" } { HTTP::redirect "http://subdomain.ourdomain.org/events/some-other-file-here-2010/speakers/speaker-list.aspx" }
- Joe_Pipitone
Nimbostratus
Thank you! Worked great - Joe_Pipitone
Nimbostratus
I stand corrected - the redirects only work in Chrome - not IE or Firefox, is there anything you see wrong?if { [string tolower [HTTP::uri]] starts_with "/lv2010/instructors" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/speakers/speaker-list.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010/hotel" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/information/hotel-and-travel.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010/register" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/information/registration.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010/fax" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/information/registration.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lasvegas10" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/home.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lasvegas2010" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/home.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010/es/register" } { HTTP::redirect "http://events.ourdomain.org/events/some-executive-page-2010/information/registration.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010/es/hotel" } { HTTP::redirect "http://events.ourdomain.org/events/some-executive-page-2010/information/hotel-and-travel.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010/es/qualify" } { HTTP::redirect "http://events.ourdomain.org/events/some-executive-page-2010/information/qualification.aspx" } if { [string tolower [HTTP::uri]] starts_with "/lv2010" } { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/home.aspx" }
- The_Bhattman
Nimbostratus
You might want switch from IF to "switch"switch -glob [string tolower [HTTP::uri]] { "/lv2010/instructors*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/speakers/speaker-list.aspx" } "/lv2010/hotel*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/information/hotel-and-travel.aspx" } "/lv2010/register*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/information/registration.aspx" } "/lv2010/fax*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/information/registration.aspx" } "/lasvegas10*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/home.aspx" } "/lasvegas2010*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/home.aspx" } "/lv2010/es/register*" { HTTP::redirect "http://events.ourdomain.org/events/some-executive-page-2010/information/registration.aspx" } "/lv2010/es/hotel*" { HTTP::redirect "http://events.ourdomain.org/events/some-executive-page-2010/information/hotel-and-travel.aspx" } "/lv2010/es/qualify*" { HTTP::redirect "http://events.ourdomain.org/events/some-executive-page-2010/information/qualification.aspx" } "/lv2010*" { HTTP::redirect "http://events.ourdomain.org/events/some-other-page-conference-2010/home.aspx" } }
- Joe_Pipitone
Nimbostratus
Are the asterisks required? - Joe_Pipitone
Nimbostratus
FYI this throws an error on the big-ip - i'm using v 9.4.7switch -glob [string tolower[HTTP::uri]] {
01070151:3: Rule [tdwi_caseins_redirects] error: line 4: [wrong args] [string tolower[HTTP::uri]]
- Joe_Pipitone
Nimbostratus
CORRECTION - it works fine, it was the needed space between tolower and [ - The_Bhattman
Nimbostratus
I hate it when that happens. :-)
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects