Forum Discussion
Chris_D_15752
Nimbostratus
May 02, 2011Mobile redirect with forced SSL
Hi guys,
I am faced with dual puzzle for site demending dual function redirect causing some issses.
I need to provide detection process from www.main.com site provide mobile type v...
Stanislas_Piro2
Cumulonimbus
Jun 15, 2015Hi,
here are two irules you can use:
redirect URL based (user agent are those defined as default in TMG to identify mobile / full user agents)
when HTTP_REQUEST {
set clientless_mode 0
Check the requested HTTP Host
if {[HTTP::host] equals "site.com"} {
Identify User-Agents type
switch -glob [string tolower [HTTP::header "User-Agent"]] {
"*blazer*" -
"*docomo*" -
"*windows ce*" -
"*symbian os*" -
"*sonyericsson*" { set clientless_mode 0 }
"*frontpage*" { set clientless_mode 1 }
"*mozilla*" -
"*opera*" { set clientless_mode 0 }
default { set clientless_mode 1 }
}
if { $clientless_mode} {
HTTP::redirect "https://m.site.com[HTTP::uri]"
return
}
} else {
pool P_mobile
}
}
redirect cookie based
when HTTP_REQUEST {
set clientless_mode 0
Check the requested Cookie
if { ![HTTP::cookie exists "MCookie"] } {
Identify User-Agents type
switch -glob [string tolower [HTTP::header "User-Agent"]] {
"*blazer*" -
"*docomo*" -
"*windows ce*" -
"*symbian os*" -
"*sonyericsson*" { set clientless_mode 0 }
"*frontpage*" { set clientless_mode 1 }
"*mozilla*" -
"*opera*" { set clientless_mode 0 }
default { set clientless_mode 1 }
}
if { $clientless_mode} {
HTTP::respond 302 noserver Set-Cookie "MCookie="mobile";path=/;secure" Location "https://m.site.com/"
return
} else {
HTTP::respond 302 noserver Set-Cookie "MCookie="full";path=/;secure" Location "https://www.site.com/"
}
} elseif {[HTTP::cookie value MCookie] equals "mobile"} {
pool P_mobile
}
}
Regards,
Stanislas
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