Forum Discussion
Joe_Pipitone
Nimbostratus
Aug 25, 2009Redirect rule somewhat working
Hello all,
I'm having a small issue with an iRule. My rule is below:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] equals "/redirectme" } {
HTTP::redirect "http://sitename.com/newuri"
}
}
This rule works just fine if you type http://sitename/redirectme.
However, the rule does not redirect if you append a / after, for example:
http://sitename/redirectme/
How can I match this so it will redirect both redirectme and redirectme/ ?
Is this possible using this type of iRule?
thank you for any help!
- Kevin_Stewart
Employee
Try: - hoolio
Cirrostratus
You could check for /redirectme or /redirect/me/ with a switch statement:when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/redirectme" - "/redirectme/" { HTTP::redirect "http://sitename.com/newuri" } } }
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/redirectme*" { HTTP::redirect "http://sitename.com/newuri" } } }
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] equals "/redirectme" or [string tolower [HTTP::uri]] equals "/redirectme/" } { HTTP::redirect "http://sitename.com/newuri" } }
- Joe_Pipitone
Nimbostratus
Thanks guys! As I was searching around I found that starts_with works perfectly! Thanks for your quick responses.
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