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

captaincroc's avatar
captaincroc
Icon for Nimbostratus rankNimbostratus
Jan 13, 2022
Solved

iRule assistance for subfolder redirect

Hi All,   iRule newbie here. I have a URL "https://blog.example.com/oldsubfolder/FBAR" that I would like redirected to "https://blog.example.com/newsubfolder/FBAR".   I tried using the below iRul...
  • CA_Valli's avatar
    Jan 14, 2022

    Hello,

    in this attempt I'm using the getfield command to split URI by "/oldsubfolder/" string, so that first "oldsubfolder" match would be field 1 and the rest of your URI will be field 2.

     

    I'm replacing /oldsubfoler/ with new path manually and then appending the rest of your uri using field 2 syntax.

     

    when HTTP_REQUEST {
     if { [HTTP::uri] contains "/oldsubfolder/"} {
       HTTP::redirect https://[HTTP::host]/newsubfolder/[getfield [HTTP::path] "/oldsubfolder/" 2]
     } 
    }  

    I haven't had the chance to test this in a lab, please do before installing.