Forum Discussion

Ts67p18's avatar
Ts67p18
Icon for Nimbostratus rankNimbostratus
Dec 17, 2020

iRule redirect

The issue is requests arrive like:

https://www.lor.edu/lorprod/items/ebb81b9e-0e6f-4bd8-af22-bf865212e2cd/1/

and we redirect to:

https://oCCC.edu/ware/lesson/ebb81b9e-0e6f-4bd8-af22-bf865212e2cd/1/

we need to remove the last /1/ if present from each request and the number may not be a "1" and may be a much larger number so that our final redirect looks like:

https://oCCC.edu/ware/lesson/ebb81b9e-0e6f-4bd8-af22-bf865212e2cd

 

our current iRule reads:

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] starts_with "/lorprod/items/" } {

HTTP::redirect "https://occc.edu/courses[string map -nocase {/lorprod/items/ /} [HTTP::uri]]"

}

}

any assistance is greatly appreciated.

2 Replies

  • Hi,

    when HTTP_REQUEST {
    	if { [string tolower [HTTP::path]] starts_with "/lorprod/items/" } {
    		HTTP::redirect "https://occc.edu/ware/lesson/[getfield [HTTP::path] / 4]"
    	}
    }
  • thank you for the quick response, i will try this immediately.

    thanks again

     

    bill