Forum Discussion

Shannon_Thompso's avatar
Shannon_Thompso
Icon for Nimbostratus rankNimbostratus
Dec 10, 2020

URL Rewrite?

This is not my realm so first time trying to do iRules, I have the following redirect code that works (remove actual site names):

 

when HTTP_REQUEST {
    set new_path [string trim [string tolower [HTTP::path]]]
    set new_site "https://abc.abc.com"
    if { $new_path eq "/reseller" } {
      HTTP::redirect "$new_site$new_path"
    } elseif { $new_path contains "/reseller/" } {
      HTTP::redirect "$new_site$new_path"
    }
}

 

but what I really need to to able for xyz.abc.com/reseller to go to abc.abc.com/reseller without the browser URL changing to abc.abc.com. Is this even possible?

  • It's possible if abs.abc.com site is accessible from the BigIP... By simply using a pool for abc.abc.com's (Even if you have to create a new one) to service requests that hit /reseller/

     

    BTW, I'd use starts_with rather than contains... Otherwise the URL /something/reseller/something will get redirected as well, which doesn't match your stated requirement https://clouddocs.f5.com/api/irules/starts_with.html

     

    i.e.

    1. Create pool for abc.abc.com
    2. Replace HTTP::redirect with POOL $pool_name (https://clouddocs.f5.com/api/irules/pool.html)

     

    H

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus

    It's possible if abs.abc.com site is accessible from the BigIP... By simply using a pool for abc.abc.com's (Even if you have to create a new one) to service requests that hit /reseller/

     

    BTW, I'd use starts_with rather than contains... Otherwise the URL /something/reseller/something will get redirected as well, which doesn't match your stated requirement https://clouddocs.f5.com/api/irules/starts_with.html

     

    i.e.

    1. Create pool for abc.abc.com
    2. Replace HTTP::redirect with POOL $pool_name (https://clouddocs.f5.com/api/irules/pool.html)

     

    H