Forum Discussion
Jerred_Weingart
Nimbostratus
Jun 17, 2016URL rewrite
I need to make an iRule that can rewrite a URL if needed. Actually I just need to add a path between a URL and a filename.
website.com/[randomfilename]
to
website.com/processor/makess...
Vijay_E
Cirrus
Jun 17, 2016I am making an assumption that the random file name is a file that ends with ".txt". You can change it to anything else you want.
The following will send a redirect and hence, the browser URL will change:
when HTTP_REQUEST {
if { ([HTTP::host] eq "website.com") and ([HTTP::uri] ends_with ".txt") } {
HTTP::uri /processor/makesstuff/here[HTTP::uri]
HTTP::respond 301 Location "http://[HTTP::host][HTTP::uri]"
}
}
This will change the URL between F5 & Server. However, you would need to provide more information on the exact URL or you can modify the following to suit your needs.
when HTTP_REQUEST {
if { ([HTTP::host] eq "website.com") and ([HTTP::uri] ends_with ".txt") } {
HTTP::uri /processor/makesstuff/here[HTTP::uri]
pool POOL_ABC
}
}
when HTTP_RESPONSE {
if { [HTTP::header values Location] contains "/processor/makesstuff/here/" } {
HTTP::header replace Location [string map {"/processor/makesstuff/here/" "/"} [HTTP::header value Location]]
}
}
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