Forum Discussion
RonR10_181817
Jun 10, 2015Nimbostratus
iRule 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"
}
}
}
}
- 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
- cjuniorNacreous
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" } } } }
- RonR10Nimbostratus
Thanks for your input!
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