Forum Discussion
Vinod_F5_212422 Nimbostratus
Nimbostratus
Jul 22, 2015Rules to redirect based on URL
 Hi,    
 I have a web application that is deployed on 3 servers also 3 URL's to them     
  Server 1 (192.XXX.XXX.XXX) ==> http:\192.XXX.XXX.XXX\  Server 2 (192.XXX.XXX.YYY) ==> http:\192.XXX.XXX.YYY...
VernonWells Employee
Employee
Jul 23, 2015... and in fact, I think I have a bit of a bug there with the non-glob matches, so here is a variant that uses a data group :).
create ltm pool pool-user1-context members add { 192.168.1.1:80 { } }
create ltm pool pool-user2-context members add { 192.168.2.1:80 { } }
create ltm pool pool-user3-context members add { 192.168.3.1:80 { } }
create ltm data-group internal dg-user-server type string records add { \
   User1 { data pool-user1-context } \
   User2 { data pool-user2-context } \
   User3 { data pool-user3-context } \
}
create ltm rule context-to-server {
when RULE_INIT {
    set static::uc_user_server_dg dg-user-server
}
when HTTP_REQUEST {
    set context [getfield [HTTP::uri] / 2]
    set swpool [class lookup $context $static::uc_user_server_dg]
    
    if { $swpool ne "" } {
        set nuri [substring [HTTP::uri] [string length "/$context"]]
        if { $nuri eq "" } {
            HTTP::uri /
        } else {
            HTTP::uri $nuri
        }
        
        pool $swpool
    }
}
}
It makes sense to define a default pool for the Virtual Server to which this rule would be applied.
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