HTTP URI Replace/Redirect

Problem this snippet solves:

When there is a Http request, this iRule looks for Uri starting with specified uri and redirects to different Host+Uri. If it does not match any uri, traffic should be dropped. Example: Uri starting with /a/1/anything/ should be redirected to www.whatever.com/a1/anything.

Code :

when HTTP_REQUEST { 
switch -glob [string tolower [HTTP::uri]] {
 "/a/1*" {
   HTTP::redirect "http://[HTTP::host]/a1*"
 }
 "/b/2*" {
 HTTP::redirect "http://[HTTP::host]/b2*"
 }
 "/c/3*" {
 HTTP::redirect "http://[HTTP::host]/c3*"
 }
 default { }
 }
}

Tested this on version:

11.5
Published Nov 09, 2016
Version 1.0

Was this article helpful?

1 Comment

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    Apologies, I Posted this as a intention for someone to take a look and correct it.