Forum Discussion
David_Stephenso
Jun 13, 2012Nimbostratus
Problems with a rewrite. Please help
Hi, I've been asked to write an irule that will intercept anything with a uri that begins with /upload and remove the /upload.
Also, the rule needs to rewrite the host from whatever it is to be ...
hooleylist
Jun 13, 2012Cirrostratus
Hi David,
Here's an example which rewrites the host header value based on the selected server IP address:
https://devcentral.f5.com/wiki/iRules.rewrite_host_header_to_server_name.ashx
You could modify that to change the URI as you need to. In pre-v11, the [HTTP::uri] value is cached within the same event. The actual value sent to the pool is updated though. If you want to log the updated value, you can do this in a later HTTP_REQUEST event:
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: Original request: [HTTP::host][HTTP::uri]"
if { [HTTP::uri] starts_with "/upload" } {
HTTP::uri [string range [HTTP::uri] 7 end]
pool pool1
}
}
when HTTP_REQUEST priority 501 {
log local0. "[IP::client_addr]:[TCP::client_port]: Current request: [HTTP::host][HTTP::uri]"
}
Aaron
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