Forum Discussion

506ADA's avatar
506ADA
Icon for Nimbostratus rankNimbostratus
Mar 23, 2022

Subfolder Redirect

I am working on trying to do a redirect based on the information below. Any help you can provide would be much appreicated. when i go to https://mainpage.com/Main I want it to hit the backend pool a...
  • Mayur_Sutare's avatar
    Mar 24, 2022

    Hi 506ADA ,

    Yes you can achive your requirement using iRule as well as LTM policy. One of the sample iRule is given below. 

    Given iRule is sample written looking at your requirement. Based on your different use cases, you may need to customize it more.

     

     

    when HTTP_REQUEST {
    
    if {([HTTP::host] equals "mainpage.com") && ([HTTP::uri] contains "secondary")} {
        
        HTTP::redirect "https://mainserver.ad.blah.blah.com[HTTP::uri]"
    } elseif {([HTTP::host] equals "mainpage.com") && ([HTTP::uri] contains "main")} {
        
        pool Default-Pool-Name
    } 
    
    }

     

     

    NOTE - Normally when none of the case is matched (in iRule and/or LTM policy), F5 vServer forwards request to default pool attached on the vServer. 

    I have also attached one sample LTM policy for your second use case of redirection. You can also customize under LTM policy as per your wish/use case.

    Hope it helps!