Forum Discussion
need to check for a path in an irule
i need to check for a path in an irule if it isn't there send it to one re-direct if it is, send it to a different re-direct
when HTTP_REQUEST {
set lhost [string tolower [HTTP::host]] set lpath [string tolower [HTTP::path]]
if { $lhost equals "itservices.ou.edu" } { if { not ($lpath starts_with "/norman") }{ HTTP::redirect "https://ouitservices.service-now.com/ess_portal" } } elseif { $lhost equals "itservices.ou.edu" } { if { ($lpath starts_with "/norman") }{ HTTP::redirect "http://itscnorman.ou.edu" } } }
2 Replies
- VernonWells
Employee
Is your code not working for you? I will say that it can be somewhat simplified, since your outside if/else conditionals check the same condition and the inner [if]s are negations of one another:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "itservices.ou.edu" } { if { [string tolower [HTTP::path]] starts_with "/norman" } { HTTP::redirect "https://ouitservices.service-now.com/ess_portal" } else { HTTP::redirect "http://itscnorman.ou.edu" } } }If you are running at least version 11.4, you should be able to accomplish this with a Local Traffic Policy, as well:
A Local Traffic Policy should, in general, be more performant, and is integrated with the web UI and CLI.
- Gary_Bristol_19
Nimbostratus
thank you, that works like a champ, except for reversing the redirection placement.
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