Replace domain of the URL using a iRule

Hello;

I am looking for a way to replace the domain of the URL using a iRule, and then redirect the user to the result.

For example:

https://home.domain.com -> replace domain.com to mydomain.net -> redirect to https://home.mydomain.net
https://bike.domain.com -> replace domain.com to mydomain.net -> redirect to https://bike.mydomain.net
But this iRule must be use for multiple URL having having the domain "domain.com"

How I can do this?

Thank you

J

is it something like this?

config

[root@ve11b:Active:In Sync] config  tmsh list ltm rule qux
ltm rule qux {
    when HTTP_REQUEST {
  if { not ([HTTP::host] contains "mydomain.net") } {
    HTTP::redirect http://[string map {domain.com mydomain.net} [HTTP::host]][HTTP::uri]
  }
}
}

 test

[root@ve11b:Active:In Sync] config  curl -I http://home.domain.com/something
HTTP/1.0 302 Found
Location: http://home.mydomain.net/something
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

[root@ve11b:Active:In Sync] config  curl -I http://bike.domain.com/something
HTTP/1.0 302 Found
Location: http://bike.mydomain.net/something
Server: BigIP
Connection: Keep-Alive
Content-Length: 0