Forum Discussion

Damien_Turner_1's avatar
Damien_Turner_1
Icon for Nimbostratus rankNimbostratus
Aug 02, 2010

Redirect if your a mobile user....

Hi all, I was wondering if I could have some help! I have been asked if it is possible to use an iRule to redirect a mobile user to a new URL. An example would be.... user on an iPhone goes to www.mysite.com but as they are a mobile user the URL gets changed to m.mysite.com and the correct formatted site is then shown. I've looked through quite a few similar topics but none seem to redirect the URL. I have a a pool of web servers but they serve all traffic, but I guess I could create anther pool. I'm still quite new to iRules but I know they rule! Thank You Damien

11 Replies

  • pmaubo2 I'd recommend you do a packet capture and inspect the User-Agent for each device and then use something like what I've put below. Just remember that User-Agent values may change between iOS and Android versions. I'm sure a quick Google would help with that.

    
    when HTTP_REQUEST {
     if { [class match [string tolower [HTTP::header User-Agent]] contains XXXX ] } {
      HTTP::redirect "http://onesite.com"
      return
        }
     elseif { [class match [string tolower [HTTP::header User-Agent]] contains XXXX ] } {
      HTTP::redirect "http://anothersite.com"
            }
    }