Forum Discussion
BigIP_Support_9
Nimbostratus
Feb 23, 2006Change URI without redirect
I want to change the user URI as below:
http://www.abc.com/demo -> http://www.abc.com/demo1
Here is my code:
if (http_uri == "/demo") {
redirect to "http://" + http_host + "/demo1/"
}
else {
if (http_uri matches_regex "/demo/") {
redirect to "http://" + http_host + "/demo1/" + substr(http_uri, 6, 1000)
}
else {
use pool demo-pool
}
}
It works but it requires too many redirect. Clients are required to use new conenction after redirect according
to RFC 2616.
In fact I just want to change demo to demo1. Can I change the URI and forward to demo-pool pool within a single "if" clause? I don't want to redirect and client go back again and falls to the last "if" clause.
- Colin_Walker_12Historic F5 AccountIt looks like you just need to work on your logic a little. Your second if clause would grab a lot of the same URIs as the first one, unless there's been something added to the "demo" in the uri.
- BigIP_Support_9
Nimbostratus
The first if-clause is to capture http://www.abc.com/demo - BigIP_Support_9
Nimbostratus
I searched and see that in v9.x iRules, we can do below, so we don't need to use REDIRECT to just to change the URI but still forward to same FQDN, same server poolif (http::uri equals "/demo") { HTTP::uri "http://" + http_host + "/demo1/" pool demo-pool } else { if (http::uri contains "/demo/") { HTTP::uri "http://" + http_host + "/demo1/" + substr(http_uri, 6, 1000) pool demo-pool } else { pool demo-pool } }
- Martin_MachacekHistoric F5 AccountThere is no way how to achieve what you want in v4.x. v9.x iRules are much more powerful.
- chief_rocka_334
Nimbostratus
I needed the same type of iRule and this worked for me with no redirects.
when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/demo/" } { HTTP::path [string map {"/demo/" "/demo1/"} [HTTP::path]] } else{ pool demo-pool } }
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