Forum Discussion

SS11's avatar
SS11
Icon for Nimbostratus rankNimbostratus
Feb 19, 2019

Redirect based on host and wildcard URI

The following logic need to implement;

 

User access link:

 

http://test.com/eai_enu/start.swe?

 

Expected:

 

https://test2iis.com/siebel/app/eai/enu?

 

if URI contains in the user link as below;

 

eai_enu>>> should capture the string before '_' and it should insert in the redirect string >> https://test2iis.com/siebel/app/eai/enu?

 

eaimob_enu >>> should capture the string before '_' and it should insert in the redirect string >> https://test2iis.com/siebel/app/eaimob/enu?

 

i am not sure how the wildcard string detect in the redirect URI and insert the string value in the redirect URI.

 

Thanks.

 

1 Reply

  • Hi SS,

    Your way:
    when HTTP_REQUEST {
    set capture_string [getfield [HTTP::uri] "/" 2]]
    set 1st_part [getfield $capture_string "_" 1 ]
    set 2nd_part [getfield $capture_string "_" 2 ]
    if { $2nd_part equals "enu" } {
    HTTP::respond 301 Location "https://test2iis.com/siebel/app/$1st_part/$2nd_part?"
    }
    }
    
    the Other way:
    when HTTP_REQUEST {
    if { [set redirection_to [class match -value [HTTP::uri] starts_with REDIRECTION_LIST]] ne "" } then
    {
    HTTP::respond 301 Location "https://test2iis.com$redirection_to?"
    }
    }
    
    ltm data-group internal REDIRECTION_LIST {
        records {
            /eai_enu {
                data /siebel/app/eai/enu
            }
            /eaimob_enu {
                data /siebel/app/eaimob/enu
            }
            }
        }
        type string
    }
    

    Edited: equals to starts_with after Andy's post.