Forum Discussion
matt_cole_24635
Nimbostratus
Jan 03, 2017iRules vs Polices
I am trying to replicate the following iRule with a LTM Policy. iRule works, policy doesnt work. Does it support regex? How can I match just a / with nothing before or after without regex? iRule:
if {[string tolower [HTTP::uri]] matches_regex {^/$}} { HTTP::redirect "; }}
Policy:
rules {
"Default Page Redirect" {
actions {
0 {
http-reply
redirect
location http://example.com/external/example.jspx
}
1 {
log
write
facility local0
message "tcl: [HTTP::path]"
priority debug
}
}
conditions {
0 {
http-uri
path
values { ^/$ }
}
}
}
1 Reply
- Stanislas_Piro2
Cumulonimbus
Hi,
First, the irule is working but is not optimized. Regex must only be used if necessary and / in uppercase and lowercase always equals / :
if {[HTTP::uri] equals "/"} { HTTP::redirect "https://example.com/external/example.jspx"; }in the policy, this is the same:
rules { "Default Page Redirect" { actions { 0 { http-reply redirect location http://example.com/external/example.jspx } 1 { log write facility local0 message "tcl: [HTTP::path]" priority debug } } conditions { 0 { http-uri path values { / } } } }
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
