Forum Discussion
Joe_Pipitone
Nimbostratus
Jan 26, 2011Stripping part of URI and integrating with iRule
I have to perform the following: http://www.oursite.org/directory1/directory2/somepage.aspx needs to rewrite to http://oursite.org/somepage.aspx - essentially just stripping out directory1 and dir...
Chris_Miller
Altostratus
Jan 26, 2011You're not "rewriting" the URI here. You're redirecting the user to a different one. For your else condition, are you just trying to direct them to their URI but without www in front of the host name? Or are you trying to redirect them to oursite.org/
With the rule above, [HTTP::uri] might contain /directory1/directory2. If it does, your first redirect is to send them to oursite.org/directory1/directory2. Naturally, that's going to be a loop. In the case of your else statement, the same logic applies.
Give this a shot
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/directory1/directory2" } {
HTTP::redirect "http://oursite.org[string range [HTTP::uri] 21 end ]"
log local0. "/directory1/directory2 found, redirected"
} else {
HTTP::redirect "http://oursite.org[HTTP::uri]"
log local0. "go to homepage"
}
}
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