change url via iRule

simple irule question, I been looking for an answer and cant find it so sorry if this was answered already.

I need an iRule that can repalce part of a url with another. Meaning if the reqeust comes for “http://www.abc.com/1234” I would like to change the user’s address bar to “.xyz Domain Names | Join Generation XYZ” or whatever the user had requested. That means the only part I like to change is between //domainname.com/ and nothing after that. So if the request for for a long url such as “http://www.abc.com/mysite/test/whatever” then I like to preserve the “/mysite/test/whatever” path and just replace the domain part.

Let me know if I’ve explained this and if this can be done via an iRule. Very much apprecaite your help in advance!

Hamid

e.g.

[root@ve1023:Active] config  b virtual bar list
virtual bar {
   snat automap
   pool foo
   destination 172.28.65.152:http
   ip protocol tcp
   rules myrule
   profiles {
      http {}
      tcp {}
   }
}
[root@ve1023:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
        if {[HTTP::host] equals "www.abc.com"} {
                HTTP::redirect "http://www.xyz.com[HTTP::uri]"
        }
}
}

[root@ve1023:Active] config  curl -IL http://www.abc.com/1234
HTTP/1.0 302 Found
Location: http://www.xyz.com/1234
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

HTTP/1.1 404 Not Found
Date: Fri, 11 Nov 2011 00:05:15 GMT
Server: Apache/2.2.3 (CentOS)
Connection: close
Content-Type: text/html; charset=iso-8859-1

Sorry for late reply nitass. Thank you very much worked like a charm!

happy holiday :slight_smile: