iRule that match rewrite policy
Hi guys,
I need to implement an iRule that works like a Rewrite profile but should change URI path (remove a part of the string) to the server side. I cannot use the normal rewrite because on the same VIP I’ve two domains and the server URI it’s the same for both, this is an example:
prod.example.com/prod/service1 -> should rewrite to /service1 when goes to server pool
test.example.com/test/service1 -> should rewrite to /service1 when goes to server pool
obviously the policy gives me error backup server URI is already used.
I’ve tried this iRule but I got error 404 from server side:
when HTTP_REQUEST {
set host [HTTP::host]
set uri [string tolower [HTTP::uri]]
if { $host equals "test.example.com" } {
HTTP::uri [string map {"/test" "" } $uri ]
}
}
any help is really appreciated
thanks