Forum Discussion
Replacing the beginning of the URI if entire URI is not explicitly allowed
New to the forum and may have bitten off more than I can chew for a newbie.
I need to create an iRule that meets the following criteria:
if HOST = "www.domain.com" AND URI starts with "/subdirectory" AND the complete URI does not equal either "/subdirectory/checkout.aspx" or "/subdirectory/orderhistory.aspx" THEN URI equals "/newplace" & remaining URI
Essentially if the domain name is true, the URI starts with /subdirectory, and is NOT either of the two specific files listed, then to replace the start of the URI to be /newplace. The intent being to push all traffic into /newplace unless one of two exceptions.
Below is what I have come up with
set STAYURI {"/checkout.aspx" "/orderhistory.aspx"}
set CHECKURI {"/subdirectory"}
if { [HTTP::host] equals "www.domain.com" } {
if {[string tolower [HTTP::uri]] starts_with CHECKURI } {
if {[string tolower [HTTP::uri]] not equals foreach x concat $CHECKURI $STAYURI } {
HTTP::uri "/newplace[string range $uri 13 end]"
}
}
am I close to achieving my objective?
2 Replies
- dgeorgeson_2230
Nimbostratus
I simplified things a bit which I believe still meets my objective. Since I have a small list of specific URI to not redirect, I rewrote the irule thusset STAYURI {"/subdirectory/checkout.aspx" "/subdirectory/orderhistory.aspx"} if { [HTTP::host] equals "www.domain.com" } { if {foreach x $STAYURI { [string tolower [HTTP::uri]] not equals x} { HTTP::uri "/newplace[string range $uri 13 end]" } }
- The_Bhattman
Nimbostratus
Hi Dgeorgeson,
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