Forum Discussion

Bruce0279's avatar
Icon for Nimbostratus rankNimbostratus
Apr 15, 2021

Base Path URL Redirect to Specific Pool

Hi there,


I'm new to this forum and looking for some help, looking to create irule that will allow base path URL to redirect traffic to a certain pool.




incoming url redirect to pool 1


incoming url redirect to pool 2




5 Replies

  • when HTTP_REQUEST {
      set vurl [HTTP::host][HTTP::path]
         if { $vurl starts_with ""} {
           pool pool_name_a
          } elseif { $vurl starts_with ""} {
           pool pool_name_b
         } else {
    # no change to traffic

    Probably something along these lines, with the more specific one first, as the less specific one otherwise will catch both.

    Another point, if you have a lot of cases, like 20+, then it'd be a good idea to change to from repeated if statements to data groups.

    If you don't need to test for domain you can remove the [HTTP::host] from the variable and the if statements

    A lot of the time you can find inspiration to irules on clouddocs. For me "if" is bit more versatile, so I'll typically use it for these shorter rules. If you have a longer rule where you test a lot on the same variable then the Switch could be better.

    The better advice would probably be to steer you towards http policies that can do this in a more user friendly/intuitive way... but I like irules.

    • Bruce0279's avatar
      Icon for Nimbostratus rankNimbostratus

      thanks Heino for your help, I'll give it a shot



  • Something sort of below. Modify the pool names accordingly

    when HTTP_REQUEST {
        set baseuri [lindex [split [string tolower [HTTP::uri]] "/"] 1]
    	if { [HTTP::uri] eq "/$baseuri" } {
    	pool pool_1
    	} else {
    	pool pool_2
  • Former Member's avatar
    Former Member

     - if you got an answer please Select As Best or Upvote contributing answers.