Forum Discussion

Galahat_287504's avatar
Galahat_287504
Icon for Nimbostratus rankNimbostratus
Aug 25, 2016

Rewrite incoming PATH

Hi All,

 

I want to access my app through F5 iRule, let say my url my.example/app1 and i want to access my.example/app1/ping.

 

When the request coming, how to rewrite /app1/ping become /ping ? because my app don't know the /app1 path. When the request /app1/ping coming, the app can not find the request but if the /ping request coming, the app will response with "pong".

 

How i can rewrite this ? Thanks for your help.

 

1 Reply

  • You can do a redirect:

    when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] contains "/app1/" } {
    HTTP::uri [string map {"/app1/" "/"} [HTTP::uri]]
    HTTP::respond 301 Location "http://[HTTP::host][HTTP::uri]"
    }
    }
    

    You can remove the "/app1/" and send the request to the server:

    when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] contains "/app1/" } {
    HTTP::uri [string map {"/app1/" "/"} [HTTP::uri]]
    }
    }