cancel
Showing results for 
Search instead for 
Did you mean: 

Subfolder Redirect

506ADA
Nimbostratus
Nimbostratus

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 associated with the VIP

But what i want to do is when i go to https://mainpage.com/secondary i want it to go to mainserver.ad.blah.blah.com/secondary

 

Is this even possible?

1 ACCEPTED SOLUTION

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.

Mayur_Sutare_0-1648099016101.png

Hope it helps!

 

View solution in original post

1 REPLY 1

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.

Mayur_Sutare_0-1648099016101.png

Hope it helps!