Forum Discussion
pvrobinsontx2_2
Nov 12, 2015Nimbostratus
iRule redirect based on uri or user-agent match logic.
Hello, looking for some direction here. I am trying create a rule which will match a specific set of uri and redirect if true to a prefered site and quit processing the irule.
If the uri doesn't ma...
Stanislas_Piro2
Nov 12, 2015Cumulonimbus
Hi,
the irule may work when :
- URI doesn't match and user agent doesn't match
- URI match and user agent doesn't match
- URI doesn't match and user agent match
But the irule may cause a tcl error when both URI and user agent match
add a
return
command after each HTTP::redirect
to leave irule.
use
HTTP::path
instead of HTTP::uri
in switch... HTTP::uri
may contain query string which can be dynamic.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path]] {
"/about_news" -
"*.pdf" {
HTTP::redirect "https://www.mysite.com[HTTP::uri]"
return
}
default {
if {[string tolower [HTTP::header User-Agent]] contains "mobile"} {
HTTP::redirect "https://www.myothersite.com[HTTP::uri]"
return
}
}
}
}
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