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...
The_Bhattman
Nimbostratus
Sep 09, 2010Hi Morten,
There are several commands referenced in the deventral wiki Click Here that can be used to make your draft more efficient as well as cut down the amount code lines in the process.
Here is quick untested example that might start you down path that you are looking for
when HTTP_REQUEST {
switch -glob [URI::path [HTTP::uri] 1 ] {
Match anything that starts with /database1
"/database1/*" {
set location [findclass [URI::path [HTTP::uri] 1 1] $::redirect_file " "]
HTTP::redirection "http://[HTTP::host]/test/web/[URI::basename]?$location[URI::query]"
}
Exact match
"/database1" {
set location [findclass [URI::path [HTTP::uri] 1 1] $::redirect_file " "]
HTTP::redirection "http://[HTTP::host]/test/web/default.aspx?$location"
}
If not match then do nothing
}
}
As you can see using the following commands "switch, HTTP::uri, HTTP::host, URI::query, URI::basename and URI::path" in effect replaced the IF statement, several set statements, and the lindex command.
I hope this helps
Bhattman
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