Forum Discussion
Bibits_102724
Nimbostratus
Sep 09, 2010Need help with a redirect iRule
Hello,
I am new to iRules, and having problems getting it to work the way I hoped it would. What I want to solve is to redirect URLs according to the three examples below.
example...
Bibits_102724
Nimbostratus
Sep 14, 2010Hello Bhattman,
Thank you for you help, much appreciated.
A switch statement seems like a good idea, I was actually wondering how I could get it to work. The reason I though of using a split and set statement is because I am thinking of "database1" as a variable, and what I must match in the redirect file. But I see now that I could think of "database1" (which can be "database2, etc) as a wildcard, and match other parts of the path.
I will have to work some more to test for eventualities, but I think some variation of the code below will work for me.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path]] {
"/test/web*" {
break do nothing, most requests match here
}
"*openurl.ashx*" {
set name [URI::path [HTTP::uri] 1 1]
set name [string range $name 0 end-1] chop the trailing back slash
set location [findclass $name $::redirect_file " "]
HTTP::redirect "http://[HTTP::host]/test/web/openurl.ashx?$location[URI::query [HTTP::uri]]"
}
default {
set location [findclass [HTTP::uri] $::redirect_file " "]
HTTP::redirect /test/web/default.aspx?$location
}
}
}
Pity it takes ages to test changes in our BigIP. The GUI there must be the slowest GUI ever invented -- some 20-30 seconds to navigate to a new page there or to make a change.
Thanks again for pointing me in the right direction.
Best regards,
Morten
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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