For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

AbhijitVichare's avatar
AbhijitVichare
Icon for Nimbostratus rankNimbostratus
May 23, 2022

iRule for URL redirect

Hello,

 

Can someone please help me with an iRule for URL redirection. 

Source URL - https://test.test.com/navigator/bookmark.jsp?desktop=Invoice&docid={C2827ADC-C4B5-4B62-9024-C7848E7CAF5F}

Target redirect URL - https://test.test.com/linkredirectservice/drl?desktop=Invoice&docid=%7BC2827ADC-C4B5-4B62-9024-C7848E7CAF5F%7D

 

Note - Target URL redirect has docid value which need sto be taken from the source URL and also the { and } in the source URL docid value needs to be conver their ascii values accordingly.

 

Thanks in advance!

 

1 Reply

  • I'm just learning iRules myself but will try to help.  There should be a pre-installed redirect Irule on the LTM.  I found one named "_sys_https_redirect".  Looks like this.

    # Copyright 2003-2006, 2012-2013, 2016, 2019. F5 Networks, Inc. See End User License Agreement ("EULA")
    # for license terms. Notwithstanding anything to the contrary in the EULA,
    # Licensee may copy and modify this software product for its internal business
    # purposes. Further, Licensee may upload, publish and distribute the modified
    # version of the software product on devcentral.f5.com.
    #
    when HTTP_REQUEST {
    HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
    }

    Below is one of my companies redirects.

    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] equals "????.com" } {
    HTTP::respond 301 Location "https://???.com[HTTP::uri]"
    }
    }

     

    Hope this helps.