Forum Discussion
Dynamic String Value iRule
Yes, try the iRule below.
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "example1.com" && [string tolower [HTTP::uri]] starts_with "/administration/data/value" } {
HTTP::respond 302 noserver Location "https://example2.com[string map -nocase {"administration" "finance"} [HTTP::uri]]"
}
}
Output:
[nvsluis@ansible ~]$ curl -v --resolve example1.com:80:192.168.178.201 http://example1.com/administration/data/value/blah
* Added example1.com:80:192.168.178.201 to DNS cache
* About to connect() to example1.com port 80 (#0)
* Trying 192.168.178.201...
* Connected to example1.com (192.168.178.201) port 80 (#0)
> GET /administration/data/value/blah HTTP/1.1
> User-Agent: curl/7.29.0
> Host: example1.com
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Moved Temporarily
< Location: https://example2.com/finance/data/value/blah
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
* Connection #0 to host example1.com left intact
[nvsluis@ansible ~]$
Have fun,
--Niels
Thanks for suggestion, not got errors anymore but the result is redirect to https://example1.com, is there any alternative scripts?
- Oct 30, 2023
As you can see with the curl output in my previous reply, the iRule is working. Could you share a similar output with curl? If the iRule that I shared with you isn't working, the specifications on your side must be different, or I misunderstood them.
- nramadanFeb 26, 2024
Nimbostratus
I'm sorry what I mean is content of "value" variable always updating, for example: today value = 1111 and tomorrow gonna changes to 2222, do you have any iRule suggestion for that condition?
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
