Forum Discussion

Sanal_Babu's avatar
Sanal_Babu
Icon for Nimbostratus rankNimbostratus
Apr 22, 2023
Solved

Redirect all request except few path

Hi , I am lookin for an irule which should redirect all request to a URL except few based on below path. /en/services/ /en/ajax/logout /en/e-service-errors All the request should redirected to h...
  • Paulius's avatar
    Apr 23, 2023

    Sanal_Babu Assuming the default pool that you would like to forward traffic to is associated to this virtual server the following iRule should do what you are looking for.

    when CLIENT_ACCEPTED priority 500 {
    
        set DEFAULT_POOL [LB::server pool]
    
    }
    
    when HTTP_REQUEST priority 500 {
    
        set URI [string tolower [HTTP::uri]]
    
        switch -- ${URI} {
            /en/services/ -
            /en/ajax/logout -
            /en/e-service-errors {
                pool ${DEFAULT_POOL}
            }
            default {
                HTTP::redirect "https://stg.bbbb.com"
            }
        }
    
    }