Forum Discussion
Tony_105617
Nimbostratus
Apr 18, 2013need a rewrite or redirect rule for URI
I have only done a little iRule scripting so any thing would be helpful.
I have a customer that wants to have a iRule that will rewrite the uri portion of a request.
here's what the...
Kevin_Stewart
Employee
Apr 18, 2013The HTTP::uri command only rewrites the URI on ingress flow. In order to see the new URI in the browser address bar you actually have to cause a redirect event, which is to say that you force the user to go to a new URL. I assumed from your original request that you were looking to just change the incoming URI, which the previous iRule will do. The browser won't see it, but the server will. If, however, you need the client to see the new address, then change out the HTTP::uri write command in the above iRule with the HTTP::redirect command:
when HTTP_REQUEST {
if { not ( [string tolower [HTTP::uri]] starts_with "/addeduri" ) } {
HTTP::redirect "/addeduri[HTTP::uri]"
}
}
The browser will make its original request, let's say "/browse.php". The iRule will see that the URI doesn't start with "/addeduri", so it will issue a 302 redirect to the client and a Location header that includes "/addeduri" and the originally requested URI (ex. "/addeduri/browse.php").
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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