Forum Discussion
Mike_Graston_10
Nimbostratus
Jan 26, 2007Adding a uri if one doesn't exist
Currently I have a url split between several pools depending on uri portion. How would I modify the Irule to insert a uri if none is present?Any help would be appreciated...
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc"} {
pool mywebsite.com-abc
}
elseif { [string tolower [HTTP::uri]] starts_with "/def"} {
pool mywebsite.com-def
}
else {
pool mywebsite.com-ghi
}
}
Now if it request comes in with just the url domain name and does not have a /* after it I want to add the /ghi/ to it?
Sort of stumped but does appear to seem it would be too difficult to do????
- Wil_Schultz_101
Nimbostratus
This should get you there!elseif { [string tolower [HTTP::uri]] equals "/"} { HTTP::respond 301 "Location" "http://my.domain.tld/ghi" }
- Colin_Walker_12Historic F5 AccountUnless I'm mis-interpreting the request, the HTTP::respond command isn't going to produce the desired results. The HTTP::respond command is going to send a response to the client, whereas I believe what xf6svrb is looking for is to modify the client's originally requested URI, if it's empty, to contain "ghi". Is that correct?
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/abc"} { pool mywebsite.com-abc } elseif { [string tolower [HTTP::uri]] starts_with "/def"} { pool mywebsite.com-def } else { if { [string length [HTTP::uri] < 2] } { HTTP::uri "/ghi/" } pool mywebsite.com-ghi } }
- Mike_Graston_10
Nimbostratus
Guys, - Leo_Katona_5507
Nimbostratus
The line:if { [string length [HTTP::uri] < 2] } {
if { [string length [HTTP::uri]] < 2 } {
- Mike_Graston_10
Nimbostratus
Thanks, that corrected the syntax error I was seeing and should have picked up on! This didn't append the /ghi/ like expected. I changed the rule to have just this in and still didn't get it to work. - Leo_Katona_5507
Nimbostratus
Does this work:when HTTP_REQUEST { if {[string equal [HTTP::uri] {/}] } { HTTP::uri {/ghi/} } }
- Mike_Graston_10
Nimbostratus
No, this didn't seem to work ever though this is my only entry in the Irule - Leo_Katona_5507
Nimbostratus
The latest simplified rule *will* work if configured correctly, so could you check - The only way to test this is to include logging statements on the BIG-IP as well as web server logging on the backend server.
when HTTP_REQUEST { log local0. "URI: [HTTP::uri]" if { [HTTP::uri] equals "/" } { log local0. "URI is empty, changing to http://[HTTP::host]/ghi..." HTTP::uri "/ghi/" } else { log local0. "URI is not empty, leaving alone..." } }
- JRahm
Admin
log "log this ..."
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