Forum Discussion
Colin_Walker_12
May 02, 2011Historic F5 Account
So basically, if I understand this correctly, you want to redirect all traffic from 80 -> 443, but with any request coming from a mobile device (as defined by your list of Use-Agents) you want to redirect them to https://m.site.com instead of https://site.com?
If that's correct, then your iRule is pretty close, and you could simply modify it to handle both cases:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::header User-Agent]] {
"*blackberry*" -
"*windows ce*" -
"*palm*" -
"*sonyericsson*" -
"*lg*" -
"*sie*" -
"*up.b*" -
"*up*" -
"*motorola*" -
"*mot-*" -
"*astel;*" -
"*j-phone*" -
"*netfront*" -
"*xiino*" -
"*iphone*" -
"*benq*" -
"*cricket*" -
"*andr*" -
"*htc*" -
"*nokia*" -
"*portalmmm *" -
"*samsung*" -
"*sec*" -
"*vodafone*" -
"*smartphone*" -
"*symbian*" {
HTTP::redirect "https://msite.web.com[HTTP::uri]"
return
}
}
if { [string tolower [HTTP::header Accept]] contains "vnd.wap.wml" } {
HTTP::redirect "https://msite.web.com[HTTP::uri]"
return
}
if { [HTTP::header exists "MSISDN"] } {
HTTP::redirect "https://msite.web.com[HTTP::uri]"
return
}
if {[TCP::local_port] != 443 }{
HTTP::redirect "https://[HTTP::host][HTTP::uri]
}
Since all of your previous logical statements have built in return statements anyway, this final if should only be executed if nothing else fired, and will do the global redirect everything to SSL functionality, so you would disable this in the profile or wherever you're doing it now and let the iRule handle it. That would, I think, solve the problem.
Colin