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

F5 LTM - iRule that will replace the host, remove the path and send traffic to the specific pool




I have a standard VIP on port 443 with SSL client and servers side profile and some pool on port 443 as well.


What I need to implement on that VIP is: when the path begins with /VPC ( for example the host name ( needs to be replaced by ( and path /VPC needs to be removed. After that this traffic ( needs to be send to the specific pool (different than default but also on port 443). I suppose the iRule is the best option here. Unfortunately I cannot make simple 302 redirect...


Of course if the URI does not begin with /VPC the traffic needs to go to the default pool.


I found some similar cases on devcentral however neither of them match all the requirements.





You can have below iRules on your VS to achieve your requirement.


iRule 1 -


when HTTP_REQUEST { if { ([HTTP::host] equals "") && ([HTTP::uri] starts_with "/vpc") } { HTTP::respond 301 Location "" } }

iRule 2 - For Pool selection


when HTTP_REQUEST { switch [HTTP::host] {   "" {pool example2_pool} } }

You can bind these iRules to your virtual server so it will match for desired requests, rest requests will be forwarded to the default pool.


Hope it helps!


Hi. I did not add that 301 also cannot be used. My bad, sorry for that The thing is that we cannot add DNS entry with So the user can only connect using and all the redirect to needs to be done on the F5. I hope it's possible. However I'm not sure if there will be an issue after the user will get the response from It's complicated 😄

Hello, please correct me if my understanding is wrong. If user access, you want to redirect request to separate pool and user/client should see URL under browser/application. And rest requests should be serve by default pool.

The rest request should also be sent to the pool for I think I understand your point. For second request there might be no VCP in the path so user with or will be directed to default pool. So...the user needs to see so his request can still be send to the second pool. Correct me if I am wrong but after the HTTP response the user will have the hostname from the web server that send him the data - Even if no redirect has been send to him before. Then the second irule would do his job.