Forum Discussion
RonR10_181817
Nimbostratus
Jun 10, 2015iRule Redirection using Switch
Hello all - I am requesting your expertise to determine why this iRule doesn't work 100%. I am trying to redirect users to a page upon entering the site.
1) http://www.site1.com or http://site1.com works correctly and redirects me to the maintenance page. 2) But if I go to http://www.site1.com/MyAccount or http://site1.com/MyAccount, it does NOT redirect me to the maintenance page.
Thanks in advance! Ron
when HTTP_REQUEST {
if { (([HTTP::host] equals "site1.com") or ([HTTP::host] equals "[www.site1.com](http://www.site1.com)")) }{
switch -glob [string tolower [HTTP::uri]] {
"/" -
"*MyAccount*"
{
HTTP::uri "/MaintenancePage.html"
}
}
}
}
3 Replies
- Michael__
Nimbostratus
Hi,
you used
- when you use string tolower you should specify the pattern also in lower case e.g. myaccount not MyAccount[string tolower [HTTP::uri]]Greets Michael
- cjunior
Nacreous
Hi,
Yes, I agree with Michael. But I would change the syntax of the condition, I'm thinking that it is confused and maybe there is a syntax error.when HTTP_REQUEST { if { [lsearch {"site1.com" "www.site1.com"} [HTTP::host]] != -1 }{ switch -glob [string tolower [HTTP::uri]] { "/" - "*myaccount*" { HTTP::uri "/MaintenancePage.html" } } } } - RonR10
Nimbostratus
Thanks for your input!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects