Forum Discussion
iRule redirect to mobile site
Hi,
I'm trying to create an iRule that will redirect users to site "www.mobilesite.com/slm/faces/m/index.jspx" if on mobile device else redirect to "https://mysite.com/OLA/faces/siteLocator.jspx". So far I have:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "www.mobilesite.com"}{
switch -glob [string tolower [HTTP::header User-Agent]] {
"*ipad*" -
"*iphone*" -
"*android*" -
"*windows phone*" -
"*windows ce*" -
"*bada*" -
"*bb10*" -
"*blackberry*" -
"*symbinos*" -
"*symbain os*" -
"*symbian*" -
"*java*" -
"*winowsphone*" -
"*windowsce*" {
HTTP::redirect "www.mobilesite.com/slm/faces/m/index.jspx"
return
}
}
}
}
- Ashish_Ram_TakaNimbostratus
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri] ]
set mobile_site "https://www.mobilesite.com"
set full_site "http://www.mobilesite.com?Ismain=true"
if {$uri contains "ismain=true" || $uri contains "xyzuri" || $uri contains "dynamicweb"} {
event disable
} else {
switch -glob [string tolower [HTTP::header User-Agent]] {
"iphone" -
"android" -
"windows phone" -
"*windows ce*" - "*bada*" -
"bb10" -
"blackberry" -
"symbinos" -
"symbain os" -
"symbian" -
"java" -
"winowsphone" -
"*windowsce*" { HTTP::redirect "https://www.mobilesite.com" return } } } }
- Ashish_Ram_TakaNimbostratusPlease try this iRule
- Ashish_Ram_Tak1Nimbostratus
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri] ]
set mobile_site "https://www.mobilesite.com"
set full_site "http://www.mobilesite.com?Ismain=true"
if {$uri contains "ismain=true" || $uri contains "xyzuri" || $uri contains "dynamicweb"} {
event disable
} else {
switch -glob [string tolower [HTTP::header User-Agent]] {
"iphone" -
"android" -
"windows phone" -
"*windows ce*" - "*bada*" -
"bb10" -
"blackberry" -
"symbinos" -
"symbain os" -
"symbian" -
"java" -
"winowsphone" -
"*windowsce*" { HTTP::redirect "https://www.mobilesite.com" return } } } }
- Ashish_Ram_Tak1NimbostratusPlease try this iRule
- Michael_JenkinsCirrostratus
I think with your iRule, you'll wind up in an endless loop for mobile clients unless you add a URI check for the redirect page. And I'm assuming that if the user agent isn't for a mobile client, you want to redirect them to the page you mentioned... Maybe something like this would work
when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains "www.mobilesite.com"}{ switch -glob [string tolower [HTTP::header User-Agent]] { "*ipad*" - "*iphone*" - "*android*" - "*windows phone*" - "*windows ce*" - "*bada*" - "*bb10*" - "*blackberry*" - "*symbinos*" - "*symbain os*" - "*symbian*" - "*java*" - "*winowsphone*" - "*windowsce*" { if {not ([string tolower [HTTP::uri]] equals "/slm/faces/m/index.jspx")} { HTTP::redirect "www.mobilesite.com/slm/faces/m/index.jspx" return } } default { HTTP::redirect "https://mysite.com/OLA/faces/siteLocator.jspx" } } } }
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