Unfortunately, the code paste was a bit mangled, so I apologize if I miss something. I will say, though, that I don't see a branch where you insert or redirect.
To start, are you interested in performing an HTTP Redirect (i.e., send back a 3xx response with a Location header), or transparent URI rewrite (change the URI before proxying the message to the pool member)? The code differs according to which you require.
If you are using 11.4.0 or greater, you can accomplish all of your objectives using a Local Traffic Policy, rather than an iRule:
https://support.f5.com/kb/en-us/solutions/public/15000/000/sol15085.html
This has several advantages: 1. it is likely faster than an iRule; 2. it is part of the standard config; and 3. it doesn't require code debugging or code expertise for those that need to understand it.
If you cannot use a Local Traffic Policy, the following iRule should accomplish what you want, assuming that an HTTP Redirect is what you're after:
when HTTP_REQUEST {
switch [HTTP::uri] {
"/dev" -
"/dev/*" {
pool P-DEV-POOL
}
"/" -
"" {
HTTP::redirect "https://example.com/weblogin"
}
}
}
Notice a few things:
- I assume you want the dev pool for any arbitrary URI beginning with the /dev path element;
- the string tolower isn't necessary unless all capitalization permutations of "dev" must be supported;
- I assume that you want to redirect to "/weblogin" only when the URI is "/" (or empty). If you want to go there regardless of the URI, then your use of "default" is naturally correct;
- I don't explicitly name the default pool. There is no need to do so if the Virtual Server default pool is set.