Forum Discussion
IRules Logic and wild care at the end
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/dsc"} {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002958"
} elseif { [string tolower [HTTP::uri]] starts_with "/kantech" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002735"
} elseif { [string tolower [HTTP::uri]] starts_with "/acvs_catalog" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?cmd=catalog&BU=15004409"
} elseif { [string tolower [HTTP::uri]] starts_with "/acvs" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004408"
} elseif { [string tolower [HTTP::uri]] starts_with "/mac" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005009"
} elseif { [string tolower [HTTP::uri]] starts_with "/tycosafetyproducts-fire-europe" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005089"
} elseif { [string tolower [HTTP::uri]] starts_with "/scansource" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004826"
} elseif { [string tolower [HTTP::uri]] starts_with "/SimplexMear" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004867"
} elseif { [string tolower [HTTP::uri]] starts_with "/te" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004768"
} elseif { [string tolower [HTTP::uri]] starts_with "/physicalsecurity" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004506"
} elseif { [string tolower [HTTP::uri]] starts_with "/swh" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002734"
} elseif { [string tolower [HTTP::uri]] starts_with "/tfbp" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004445"
} elseif { [string tolower [HTTP::uri]] starts_with "/scott" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002988"
} elseif { [string tolower [HTTP::uri]] starts_with "/bentel" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"
} elseif { [string tolower [HTTP::uri]] starts_with "/surgard" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"
} elseif { [string tolower [HTTP::uri]] starts_with "/amerdyn" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002733"
} elseif { [string tolower [HTTP::uri]] starts_with "/cemsys" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002736"
} elseif { [string tolower [HTTP::uri]] starts_with "/ADTContractors" } {
HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005329"
} else {
pool TIRCAP_76.24-80
}
}
THANKS IN ADVANCE
16 Replies
- Scott_82504
Nimbostratus
I got it addded in,, but know the redirects are not working. These things can drive you crazy
when RULE_INIT {
set ::ForwardList [list / .html .htm .asp .pl ]
}
when HTTP_REQUEST {
if { ( not ( \
([string tolower {[HTTP::uri]}] starts_with "/knav/nav") or \
([string tolower "http://[HTTP::host][HTTP::path]"] eq \
"http://lmsadmin2.tyco-training.com/assembler/dev") \
)) and ([matchclass [HTTP::path] ends_with $::ForwardList]) \
} {
switch -glob [string tolower [HTTP::uri]] {
"/dsc*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002958" }
"/kantech*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002735" }
"/acvs_catalog*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?cmd=catalog&BU=15004409"}
"/acvs*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004408"}
"/mac*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005009"}
"/tycosafetyproducts-fire-europe*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005089"}
"/scansource*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004826"}
"/simplexmear*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004867"}
"/te*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004768"}
"/physicalsecurity*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004506"}
"/swh*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002734"}
"/tfbp*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004445"}
"/scott*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002988"}
"/bentel*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/surgard*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/amerdyn*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002733"}
"/cemsys*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002736"}
"/adtcontractors*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005329"}
default
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=10003010" }
}
}
} - hoolio
Cirrostratus
I think one issue is that this:
[string tolower {[HTTP::uri]}]
would return a literal string of [http::uri]. The curly braces prevent [HTTP::uri] being evaluated. You can remove them and it should work:
[string tolower [HTTP::uri]]
Aaron - Scott_82504
Nimbostratus
I am think I am getting closer. Thanks for all the help so far. Here is the issue
Everytime it sees a jpg or css file it trys to redirect it so the jpg never comes up...it just redirects it to the default page on the bottom of the IRULE. see below
+ 0.8340.096499142GET302Redirect to http://lms2.tyco-training.com/knav/nav?BU=10003010http://lms2.tyco-training.com/knav/TKMStyleSheet/default/images/tyco_bgimage.jpg
when RULE_INIT {
set ::ForwardList [list / .html .htm .asp .pl .jpg .css]
}
when HTTP_REQUEST {
if { ( not ( \
([string tolower [HTTP::uri]] starts_with "/knav/nav") or \
([string tolower "http://[HTTP::host][HTTP::path]"] eq \
"http://lmsadmin2.tyco-training.com/assembler/dev") \
)) and ([matchclass [HTTP::path] ends_with $::ForwardList]) \
} {
switch -glob [string tolower [HTTP::uri]] {
"/dsc*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002958" }
"/kantech*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002735" }
"/acvs_catalog*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?cmd=catalog&BU=15004409"}
"/acvs*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004408"}
"/mac*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005009"}
"/tycosafetyproducts-fire-europe*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005089"}
"/scansource*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004826"}
"/simplexmear*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004867"}
"/te*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004768"}
"/physicalsecurity*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004506"}
"/swh*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002734"}
"/tfbp*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004445"}
"/scott*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002988"}
"/bentel*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/surgard*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/amerdyn*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002733"}
"/cemsys*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002736"}
"/adtcontractors*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005329"}
default
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=10003010" }
}
}
} - Scott_82504
Nimbostratus
Like always they have changed my requirements for the web app LB. here what they need me to do
Goes to this site
www2.tyco-training.com
Redirect to
http://lms2.tyco-training.com/knav/nav?BU=10003010
Goes to this site
www2.tyco-training.com/anything <----- whatever they type there could be /ABC or /hghdnsie
Redirect to
http://lms2.tyco-training.com/knav/nav?BU=10003010
Goes to
www2.tyco-training.com/dsc
Redirect to
http://lms2.tyco-training.com/knav/nav?BU=15002958
Goes to
http://lms2.tyco-training.com/kantech
Redirect to
http://lms2.tyco-training.com/knav/nav?BU=15002735
I need to make sure everything pass such as graphics. Do I need that forward list ? or better way to do it ?
For a graphic a url could be
http://lms2.tyco-training.com/knav/TKMStyleSheet/DSC_Customers/images/tyco_bgimage.jpg ( if I dont have the forward list (could become hugh) I will run into issue it would send it to the default page)
Here are rules I have tried , I want to see what the best logic is
This is the current one I have ( I know I need to remove the following line trying to remove it the proper what with out messing up my rules)
"http://lmsadmin2.tyco-training.com/assembler/dev")
Here is my current rule
when RULE_INIT {
set ::ForwardList [list / .html .htm .asp .pl .jpg .css .jsp .gif]
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/knav/nav") or
([string tolower "http://[HTTP::host][HTTP::path]"] eq
"http://lmsadmin2.tyco-training.com/assembler/dev") or
([matchclass [HTTP::path] ends_with $::ForwardList]) } {
return
} else {
switch -glob [string tolower [HTTP::uri]] {
"/dsc*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002958" }
"/kantech*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002735" }
"/acvs_catalog*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?cmd=catalog&BU=15004409"}
"/acvs*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004408"}
"/mac*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005009"}
"/tycosafetyproducts-fire-europe*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005089"}
"/scansource*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004826"}
"/simplexmear*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004867"}
"/te*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004768"}
"/physicalsecurity*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004506"}
"/swh*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002734"}
"/tfbp*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004445"}
"/scott*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002988"}
"/bentel*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/surgard*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/amerdyn*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002733"}
"/cemsys*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002736"}
"/adtcontractors*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005329"}
default
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=10003010" }
}
}
} - Scott_82504
Nimbostratus
Ignore the post above. I have it up and running once again 90 percent. thanks
Here are my issue
Goes to this site This is not working
www2.tyco-training.com
Redirect to
http://lms2.tyco-training.com/knav/nav?BU=10003010
I need to make sure everything pass such as graphics. Do I need that forward list ? or better way to do it
For a graphic a url could be
http://lms2.tyco-training.com/knav/TKMStyleSheet/DSC_Customers/images/tyco_bgimage.jpg ( if I dont have the forward list (could become hugh) I will run into issue it would send it to the default page)
Here current irule
when RULE_INIT {
set ::ForwardList [list / .html .htm .asp .pl .jpg .css .jsp .gif]
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/knav/nav") or
([string tolower [HTTP::uri]] starts_with "/") or
([matchclass [HTTP::path] ends_with $::ForwardList]) } {
return
} else {
switch -glob [string tolower [HTTP::uri]] {
"/dsc*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002958" }
"/kantech*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002735" }
"/acvs_catalog*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?cmd=catalog&BU=15004409"}
"/acvs*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004408"}
"/mac*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005009"}
"/tycosafetyproducts-fire-europe*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005089"}
"/scansource*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004826"}
"/simplexmear*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004867"}
"/te*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004768"}
"/physicalsecurity*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004506"}
"/swh*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002734"}
"/tfbp*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15004445"}
"/scott*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002988"}
"/bentel*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/surgard*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002959"}
"/amerdyn*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002733"}
"/cemsys*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002736"}
"/adtcontractors*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15005329"}
"/*"
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=10003010"}
default
{ HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=10003010" }
}
}
} - hoolio
Cirrostratus
Requests for extensions which are defined in the forward list should not be redirected. So the .jpg request should make it to the pool without the full filename/path being defined in the forward list.
You could add some logging to the iRule, test and then check the /var/log/ltm log file. Here is a sample of the logging you could use:when RULE_INIT { set ::ForwardList [list / .html .htm .asp .pl .jpg .css .jsp .gif] } when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New request to [HTTP::uri] (path: [HTTP::path])." if { ([string tolower [HTTP::uri]] starts_with "/knav/nav") or ([string tolower [HTTP::uri]] starts_with "/") or ([matchclass [HTTP::path] ends_with $::ForwardList]) } { log local0. "[IP::client_addr]:[TCP::client_port]: Matched logic to skip redirects." return } else { switch -glob [string tolower [HTTP::uri]] { "/dsc*" { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::path] matched /dsc*." HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002958" } "/kantech*" { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::path] matched /kantech*." HTTP::redirect "http://lms2.tyco-training.com/knav/nav?BU=15002735" } ... } } }
Aaron
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
