Forum Discussion

Muthu_63814's avatar
Muthu_63814
Icon for Nimbostratus rankNimbostratus
Sep 22, 2015

iRule for Redirect URI based on string

Hello ,

 

I want to redirect URI based on the URI string as mentioned below .

 

Can someone please help me to write the irule for below requirements

 

Not Transformed: ORIGINAL URL: This will pass through unchanged:

 

https://eysso.xyz.com/eysso/sso_login.aspx

 

Transformed: ORIGINAL URL:

 

https://eysso.xyz.com/eysso/sso_login.aspx?DeepLinkKey=5218c74f-5047-4228-9a6b-656b761e4fac

 

SHOULD BE TRANSFORMED TO:

 

https://eysso.xyz.com/eygsso/sso_login.aspx?DeepLinkKey=5218c74f-5047-4228-9a6b-656b761e4fac

 

Regards, Muthu

 

2 Replies

  • Hi,

    try this local traffic policy (version 11.4.0 and above) instead of irule:

     

    ltm policy Pol_eysso {
        controls { forwarding }
        requires { http }
        rules {
            DeepLinkKey {
                actions {
                    0 {
                        http-uri
                        replace
                        path /eygsso/sso_login.aspx
                    }
                }
                conditions {
                    0 {
                        http-uri
                        path
                        values { /eysso/sso_login.aspx }
                    }
                    1 {
                        http-uri
                        query-parameter
                        name DeepLinkKey
                        values { - }
                    }
                }
                ordinal 1
            }
        }
        strategy first-match
    }
    

     

    to install it, execute in tmsh load sys config merge from terminal and paste the code.

    you can then enable it in virtual server.

  • Hi,

    the - character is not the good filter...

    replace the policy by:

     

    ltm policy Pol_eysso {
        controls { forwarding }
        requires { http }
        rules {
            DeepLinkKey {
                actions {
                    0 {
                        http-uri
                        replace
                        path /eygsso/sso_login.aspx
                    }
                }
                conditions {
                    0 {
                        http-uri
                        path
                        values { /eysso/sso_login.aspx }
                    }
                    1 {
                        http-uri
                        query-parameter
                        name DeepLinkKey
                        contains
                        values { 0 1 2 3 4 5 6 7 8 9 }
                    }
                }
                ordinal 1
            }
        }
        strategy first-match
    }