F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

Tom_90789's avatar
Tom_90789
Icon for Nimbostratus rankNimbostratus
Jul 17, 2009

Change part of HTTP::host based on User Agent

I am trying to change the HTTP:host for a HTTP::redirect based on the UserAgent identified.

 

I am able to make it work using a static host, and changing to a different static host, base on the UserAgent, however, we have several mobile web sites, and the logic is if the User Agent detected is in my list, then modify the HTTP::host to m.domain.com but if it is not a mobile device, then send it to www2.domain.com.

 

 

request to www.domain.com/someuri/goeshere

 

if mobile go to m.domain.com/someuri/goesher

 

if not mobile go to www2.domain.com/someuri/goeshere

 

 

 

 

 

 

This is where I am with it...

 

 

when HTTP_REQUEST {

 

set host [HTTP::host]

 

set ua [string tolower [HTTP::header "User-Agent"]]

 

set hostman [split $host "."]

 

if { [matchclass $ua contains $::useragent_list] } {

 

set hostman [lreplace $hostman 0 0 m]

 

[join $hostman "."]

 

{HTTP::redirect] "http://$hostman[HTTP::uri]"}

 

else {

 

set hostman [lreplace $hostman 0 0 "www2"]

 

[join $hostman "."]

 

[HTTP::redirect] "http://$hostman[HTTP::uri]"}

 

}

 

}

14 Replies

  • It would be contained in a class object that you defined within the LTM's GUI

     

     

     

    CB

     

     

  • it is a list on the big IP itself... the user agent list is fairly static for us, so the list works fine, and its easy to modify anyway, through the GUI or command line.
  • it is a list on the big IP itself... the user agent list is fairly static for us, so the list works fine, and its easy to modify anyway, through the GUI or command line.
  • it is a list on the big IP itself... the user agent list is fairly static for us, so the list works fine, and its easy to modify anyway, through the GUI or command line.