Forum Discussion
David_Barrett_2
Nimbostratus
Jan 04, 2006Hiding redirects
I have a question for writing an iRule on a 9.x
The application people would like the Big IP to take one URL and redirect to another URL or specify a URI under the first URL or redirect to ...
unRuleY_95363
Jan 04, 2006Historic F5 Account
This is actually what we term "rewriting" the url as opposed to "redirecting" it.
On an incoming request you can modify both the host header and/or the uri of the request.
To modify the host header, use the command:
HTTP::header "Host" $valuewhere $value represents the new value for the host. However, modifying the host maybe unnecessary as the BIG-IP is really choosing the host from a collection of pool members based on the load-balancing method. Usually, the Host header is used merely to record what host the original request was targeting. It's also used for virtual hosting so that the web server can sort out what host the request was targeted to. Since the BIG-IP is usually making this decision through the pool member selection you may not even need to change the Host header.To modify the uri, use the command:
HTTP::uri $new_uriThis will change the uri of the request to the one specified by $new_uri.The biggest caveat to "rewriting" the uri is that any references in the returned content will not necessarily be modified. If the server takes care to always use relative references, then things generally will work out ok. However, if the content contains absolute references, then the client will either eventually discover the new uri, or it may not even function as the new uri may not be accessible by the client. To correct for this the content can also be searched and replaced. We have a couple of methods for doing that but they all add a bit of complexity to the problem. One approach is to buffer the response and then search and replace it. This is often the easiest solution because any changes to the content likely need to have the Content-Length updated. The Content-Length header is at the beginning of the response and so you just can't search and replace without buffering the response since you need to know the new resulting length before updating the Content-Length header. Another approach is to have the BIG-IP transform the request to a chunked response and then use the stream profile to search for and replace any transformed uris.
Hopefully this helps!
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