Forum Discussion
OCC_68606
Jun 14, 2011Nimbostratus
iRule Redirect Mobile Site
I have this iRule to identify mobile browser, for example apple devices:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "www.mainsite.com" } { ...
nitass
Mar 06, 2013Employee
if you want only one page, is this usable?
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.252:443
ip protocol 6
rules myrule
profiles {
clientssl {
clientside
}
http {}
tcp {}
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if { [HTTP::host] equals "home.example.co.in" } {
if { [URI::query "?&[HTTP::query]" main] equals "true" } {
return
}
if { [string tolower [HTTP::header "User-Agent"]] contains "iphone" } {
HTTP::redirect "https://lite.example.co.in"
}
} elseif { [URI::query "?&[HTTP::query]" main] equals "true" } {
HTTP::redirect "https://home.example.co.in?main=true"
}
}
}
[root@ve10:Active] config curl -Ik https://home.example.co.in/something -H "User-Agent: iphone5"
HTTP/1.0 302 Found
Location: https://lite.example.co.in
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -Ik https://lite.example.co.in/something?main=true -H "User-Agent: iphone5"
HTTP/1.0 302 Found
Location: https://home.example.co.in?main=true
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -Ik https://home.example.co.in?main=true -H "User-Agent: iphone5"
HTTP/1.1 200 OK
Date: Wed, 06 Mar 2013 11:27:51 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
ETag: "4183f3-59-f28f94c0"
Accept-Ranges: bytes
Content-Length: 89
Content-Type: text/html; charset=UTF-8
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