Forum Discussion
Tom_90789
Nimbostratus
Jul 17, 2009Change 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
- The_Bhattman
Nimbostratus
It would be contained in a class object that you defined within the LTM's GUI
CB - Tom_90789
Nimbostratus
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. - Tom_90789
Nimbostratus
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. - Tom_90789
Nimbostratus
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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