Forum Discussion
Use of switch -glob statement to switch the traffic in place of if or elseif statement in Irule
Here is a starting point. I removed the "return"s, so you will have to put them back.
when HTTP_REQUEST { switch -glob [HTTP::uri] { "/" { HTTP::redirect "http://[HTTP::host]/SEUILibrary/controller/Lenovo:Enter" log local0. "redirecting to http://www.lenovo.com/us/en" return } "/console" { HTTP::redirect "http://canadauat.leni2.com" } "/login.workflow:Enter" { HTTP::redirect "http://canadauat.leni2.com" } ":SiteStatus" { HTTP::redirect "http://canadauat.leni2.com" } "/seapibroker" { HTTP::redirect "http://canadauat.leni2.com" } "/Author" { HTTP::redirect "http://canadauat.leni2.com" } default { HTTP::redirect "http://somewhere.anywhere.com/last/resort.aspx" } } }
If this is a website that you are concerned about search-engine rankings, you may consider using 301 redirects: HTTP::respond 301 Location "http://somewhere.anywhere.com/last/resort.aspx" Also if you did - switch -glob [string tolower [HTTP::uri]], then if somebody did not type in the case correctly, it would still work (of course, you would have to make all of your match-cases lower case. Hope this helps.
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