Forum Discussion
can anyone provide f5 script
need script to change
url (10.x1.y1.z1) to be changed to
6 Replies
Hi Chakkaravarthy,
i guess noone could write you an Script without additional information of which type of an URL you're trying to change?
Do you want to change a Request URL?
Do you want to change a delivered Redirect URL?
Do you want to perform a redirect from the old URL to the new URL?
Do you want to change a Referer URL?
Do you want to change a clickable link within some web content?
Every mentioned scenario needs completely different actions. So I encourage you to write some additional information of what your current objective is...
Cheers, Kai
- chakkaravarthy2
Nimbostratus
hello kai
thanks for your quick reply
I want to change from old URL to new URL. hope this clarifies
Hi Chakkaravarthy,
it doesn't clarify that much, since there is not "the one an only URL".
An URL is per definition just a standarized language to specify a location. But in term of webtraffic it can be a "referer URL", a "request URL", a "redirect URL" or a "clickable link" within some content.
Furthermore, the "i want to change" could be a "rewrite" or a "reroute" depending of the URL type.
Cheers, Kai
- chakkaravarthy2
Nimbostratus
current url is (10.x1.y1.z1
and this has to be re-written as
- Samir_Jha_52506
Noctilucent
Information is not sufficient. I guess you wanted to redirected from Old URL to New URL? As per details, it look like you have given back-end server hostname & port. Please write some more words.
- VernonWells
Employee
If you want to perform a redirect (that is, respond to user-agent with a 302 and a Location header):
when HTTP_REQUEST { if { [getfield [HTTP::host] : 1] eq "x1y1z1.xyzglobal.local" } { HTTP::redirect "http://x2y2z2.x2y2z2global.local:8080[HTTP::uri]" } }If you care to redirect only when the uri-path is "/":
when HTTP_REQUEST { if { [HTTP::path] eq "/" and [getfield [HTTP::host] : 1] eq "x1y1z1.xyzglobal.local" } { HTTP::redirect "http://x2y2z2.x2y2z2global.local:8080[HTTP::uri]" } }This assumes that this iRule is attached to a Virtual Server listening on port 8080.
If you want to transparently transform the Request-URI (that is, change it before sending it to the pool member, but retain original URL for user-agent):
when HTTP_REQUEST { if { [getfield [HTTP::host] : 1] eq "x1y1z1.xyzglobal.local" } { HTTP::host "x2y2z2.x2y2z2global.local" } }Having said all of that, it actually looks like you want to perform a redirect such that if the request is for then the target is . If this is the case, then the trick is, of course, the extraction. Assuming that the pattern is strictly x1y1z1.xyzglobal.local (and x, y and z are exactly one digit each), then:
when HTTP_REQUEST { if { [scan [getfield [HTTP::host] : 1] "%1d1%1d1%1d1.%3dglobal.local" a1 a2 a3 b] == 4 } { if { "$a1$a2$a3" eq $b } { HTTP::redirect "http://${a1}2${a2}2${a3}2.${a1}2${a2}2${a3}2global.local:8080[HTTP::uri]" } } }Again, if you want transparent rewriting, then you must use
with the rewritten Host header.HTTP::host
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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