Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

iRule for URL redirect

AbhijitVichare
Nimbostratus
Nimbostratus

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-C7848E7C...

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

 

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 1

Jonathancert
Nimbostratus
Nimbostratus

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.