Forum Discussion
Common Host redirect with different URIs
Hi,
What I thought was quite a simple issue, but am struggling to resolve.
I would like to redirect to a pool, lets say POOL_1 with one node (at the moment) http://1.2.3.4:8080/uri_x and then secondly to redirect to another pool, POOL_2 with another single server but same uri - http://4.3.2.1:8080/uri_x
Whilst apparently initially working, opening 2 tabs causes the first tab with site 1 to change to site 2 if site 2 is opened on tab 2. Also, a refresh of either page after some time brings about a 404 - but am guessing that this is because of nothing accounting for
I have tried the following initially but have been round in circles with switch, string map, and various persistence settings - all without any progress. We rewrite 'all' in the http profile because of the application.
Any help really appreciated. Thank you.
if {([HTTP::host] equals "site1") && ([HTTP::uri] starts_with "/uri_1")} {
pool POOL_1
HTTP::redirect "/uri_x"
}
elseif {([HTTP::host] equals "site1") && ([HTTP::uri] starts_with "/uri_2")} {
pool POOL_2
HTTP::redirect "/uri_x"
}
- Gonzalex_330537
Cirrostratus
The reason your script is not working is because of the 'HTTP::redirect "/uri_x"' command. The redirect command is only sending a redirect to the client and forcing a reconnection back to the virtual server. The redirect command is not actually doing anything to the backend servers (pool members).
Instead of the redirect, edit and change the actual uri string, before the "pool [...]" command. Something like this:
HTTP::uri = "/uri_x"
if (criteria_A) { HTTP::uri = "/uri_x" pool pool_A } elseif (criteria_B) { HTTP::uri = "/uri_x" pool pool_B }
DON'T FORGET TO ASSIGN A DEFAULT POOL FOR A CATCH ALL SITUATION. That should do the trick.
Normal syntax for redirect would be ==> HTTP::redirect "; In your case, you want to change URL. Follow example in the link below: https://clouddocs.f5.com/api/irules/HTTP__uri.html
 
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com