Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a URI using IRULE

Sukesh123456_25
Altostratus
Altostratus

I want to add a URI using an irule. I saw different articles but could not find any one exactly matching my requirement.

 

Below is the requirement.

 

When I hit a VIP it should add a URI at the end. For example,

 

> /prl-ws//

 

Any help would be really appreciated.

 

Thanks!

 

3 REPLIES 3

Try this:

when HTTP_REQUEST {
if { [HTTP::uri] equals "/"}
 {
    HTTP::redirect "https://[HTTP::host]/prl-ws//"
 }
}

Stanislas_Piro2
Cumulonimbus
Cumulonimbus

Do you want to redirect (HTTP response 302 or 307 with new URL location header) or forward with new URI.

 

If you want to redirect use this code (Never insert the Host header in the redirect if the protocol and the host are the same than the client request):

 

when HTTP_REQUEST {
     don't evaluate the uri but the path (without query string) 
    if { [HTTP::host] equals "restricted-list" && [HTTP::path] equals "/"} {
         Change only the path part, keep the query string
         Use 307 instead of 302 (default redirect command) to force the client to post data if the first request was a POST.
        HTTP::respond 307 Location "/prl-ws/[HTTP::uri]"
    }
}

If you want to forward and change the URI in serverside request

 

when HTTP_REQUEST {
     don't evaluate the uri but the path (without query string) 
    if { [HTTP::host] equals "restricted-list" && [HTTP::path] equals "/"} {
         Change only the path part, keep the query string
        HTTP::path "/prl-ws//"
    }
}

Apprecaited your help