F5 iRule to replace host to path

Hi Team,

Can someone please help me to create iRule to  achieve below requirement.

I have created one VS " vs_mule-dev-azure-lb.ucsf.edu_443 and want to route the traffic as below

https://mule-dev-azure-lb.ucsf.edu/dev-versa-chatapi-functions/api/… --->  https://dev-versa-chatapi-functions.azurewebsites.net/api/…

https://mule-dev-azure-lb.ucsf.edu/dev-versa-streaming-functions/api/… ---> https://dev-versa-streaming-functions.azurewebsites.net/api/.

Hi msaud,

Can you test the iRule?

when HTTP_REQUEST {
    if { [HTTP::host] eq "mule-dev-azure-lb.ucsf.edu" && [getfield [HTTP::path] "/" 3] eq "api" } {
        HTTP::redirect "https://[getfield [HTTP::path] "/" 2].azurewebsites.net[getfield [HTTP::uri] [getfield [HTTP::path] "/" 2] 2]"
        return
    } 
}

Thanks @Enes_Afsin_Al

Let me test the same.

Do you need rewrite on the serverside session or redirect on the clientside (visible in the browser)?. iRule will change depending on the exact requirement.

Hi ,

exact iRule requirement is :

when client call it should be routed look like below on pool:

pool_mule-dev-azure-lb_dev-versa-chatapi_443

https://mule-dev-azure-lb.ucsf.edu/dev-versa-chatapi-functions/api/… --->  https://dev-versa-chatapi-functions.azurewebsites.net/api/…

and

https://mule-dev-azure-lb.ucsf.edu/dev-versa-streaming-functions/api/… ---> https://dev-versa-streaming-functions.azurewebsites.net/api/.

pool_mule-dev-azure-lb_dev-versa-streaming_443