Forum Discussion

Ardie_6003's avatar
Icon for Nimbostratus rankNimbostratus
Jan 13, 2011

Need help on HTTP Redirection



I'm new to the F5. Need some expert advise on this.



I have 2 url.


a) www.x.x


b) mobile.x.x



Both shared the same servers, virtual servers & public IP (don't know if this is advisable). The only difference is www using port 80 while mobile port 84 for example.



I have create


1. Pools


2. Virtual Server



Should I create an iRules for this? I want when users hit mobile, it redirect to port 84.



I've copy from somewhere..





set my_uri [string tolower [HTTP::uri]]


if { $my_uri starts_with "/mobile.x/" } {


HTTP::redirect "http://mobile.x.x"







Is this rules correct? Or is there any additional rules I have to create? How to points this Rules to Virtual Server or Pools?




Please advise on this. Thanks.


2 Replies

  • assuming you have two pools, one for www with members defined with port 80, the other for mobile with members defined with port 84, you can do something like this:

    when HTTP_REQUEST {
      if { [getfield [string tolower [HTTP::host]] "." 1] eq "www" } {
        pool www_pool
      } elseif { [getfield [string tolower [HTTP::host]] "." 1] eq "mobile" } {
          pool mobile_pool
      } else { pool default }
  • of course, this assumes you are on v9 or newer. I assume this is the case even though the post is in the v4 forum. If you need v4, I'll have to check, it's been over six years since I've touched it.