conditional iRule for X-Forward-for

I have a requirement where client wants x-forward-for work in conditional manner. For example if client/user access abc.com then x-forward-for should not work but if client/user access abc.com/xyz, it should append client’s ip.

Can we achieve this with irule? if yes can someone please help me with a code?

Thanks

Hi, this iRule should do what you require

when HTTP_REQUEST {
    if {([HTTP::host] equals "abc.com") && ([HTTP::uri] starts_with "/xyz")} {
        HTTP::header insert X-Forwarded-For [IP::client_addr] 
    }
}