Forum Discussion
Need help on uri redirection i-rule
when HTTP_REQUEST {
if {([HTTP::uri] starts_with "/useradmin") or ([HTTP::uri] starts_with "/sld") or ([HTTP::uri] starts_with "/nwa") or ([HTTP::uri] starts_with "/index.html") or ([HTTP::uri] starts_with "/irj/go/km/docs/documents") or ([HTTP::uri] starts_with "/monitoring/SystemInfo") or ([HTTP::uri] starts_with "/uddiclient") or ([HTTP::uri] starts_with "/webdynpro/welcome/Welcome.jsp") or ([HTTP::uri] starts_with "/wsnavigator")} {
HTTP::redirect "https://straight2axis.axisbank.co.in/irj/portal"}
}
However, the user's requirement now states that any incoming request only to these specific context paths:
/irj/go/km/docs/documents/AxisBank/* OR /irj/go/km/docs/documents/AxisBank/^
SHOULD NOT get redirected to the Login Page, it sholud fwd as it is
6 Replies
For that many If's, I'd move to a switch statement. Plus it gives you an easy way to OR conditionals. The following will redirect to the straight2axis.axisbank.co.in link. The other two requests ( I was guessing what you wanted to do with the "^" in the second URL btw. You may have to change that ) will pass through as is. All other URI's will pass through as well unless you put something in the default case. If the default case is a passthrough though, you can just omit the two "OR'd" conditions as they will do the same thing as all other URIs.
when HTTP_REQUEST { switch -glob [HTTP::uri] { "/useradmin*" - "/sld*" - "/nwa*" - "/index.html*" - "/irj/go/km/docs/documents*" - "/monitoring/SystemInfo*" - "/uddiclient*" - "/webdynpro/welcome/Welcome.jsp*" - "/wsnavigator*" { HTTP::redirect "https://straight2axis.axisbank.co.in/irj/portal" } "/irj/go/km/docs/documents/AxisBank/*" - "/irj/go/km/docs/documents/AxisBank/^*" { Do nothing - allow to pass through } default { TODO: Do something for all other requests here } } }Hope this helps...
-Joe
- Kevin_Stewart
Employee
I would first highly recommend throwing all of those URIs into a data group. So if you did that, you might try something like this:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/irj/go/km/docs/documents/AxisBank" } { return } elseif { [class match [string tolower [HTTP::uri]] starts_with my_uri_dg] } { HTTP::redirect "https://straight2axis.axisbank.co.in/irj/portal" } } - Torti
Cirrus
hi,
- use switch instead of if! Its easier to read and a little bit faster. link text
- you have to put everything in the right order. "/irj/go/km/docs/documents/AxisBank/" will be covered by "/irj/go/km/docs/documents/". So if you want to do other things (no redirect) with every request containing AxisBank, you have to select it first.
try this one:
switch -glob [HTTP::uri] { "/irj/go/km/docs/documents/AxisBank/*" { do nothing - let through } "/irj/go/km/docs/documents/*" - "/useradmin*" - "/uddiclient" - "..." { HTTP::redirect "https://straight2axis.axisbank.co.in/irj/portal" } }regards
- Arie
Altostratus
Rumor has it that Switch is faster up to about 100 entries. Also, keep in mind that updating datagroups results in errors for a brief period of time. You can prevent this by first verifying that the group exists (it gets deleted and re-created during an update), but depending how the group is updated not all entries are immediately present in the datagroup.
- Arie
Altostratus
Lastly, I noticed that you're using a 302 (Found). If you're confident that you will always want to redirect to the new URL I'd recommend a 301:
HTTP::respond 301 Location "https://straight2axis.axisbank.co.in/irj/portal" - acgutierrez_123
Nimbostratus
Hi Kris, I'm trying to do exactly the same as you want to do with this irule, does it work for you?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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