cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Redirect all under the part of uri

Hien_Truong
Cirrus
Cirrus

Hi,

i have trouble to redirect " * " under part of uri. The below is one redirect:

 

https://www.abc.com/defe/* redirect to https://sample.com/redirect-to-legacy/new-defe/*

 

Below is my irule it works but it not redirect as expect, do you know how to redirect it?

 

when HTTP_REQUEST { 

 if { [HTTP::host] equals "www.abc.com" } 

 {

 switch -glob [HTTP::path]

 {

  "/defe/*"

  {

   HTTP::respond 301 Location "https://sample.com/redirect-to-legacy/new-defe/*"

   }

}

}

}

2 REPLIES 2

Hi Hien Truong,

 

Can you try this?

when HTTP_REQUEST { if { [HTTP::host] equals "www.abc.com" && [HTTP::path] starts_with "/defe/" } { set newpath [string map {"/defe/" "/redirect-to-legacy/new-defe/"} [HTTP::path]] HTTP::respond 301 Location "https://sample.com$newpath" } }

 

 

Hien_Truong
Cirrus
Cirrus

​it works, thanks a lot.