Forum Discussion

mikey_webb's avatar
Mar 29, 2021

irule to redirect uri - help

 

i have a redirect based on country which works www.abc.com if in uk redirects to uk.abc.com

I need to redirect but also to retain a catalogue number so for example www.abc.com/catalogue/book/3333 redirects to uk.abc.com/catalogue/book/3333

For this the below works well

   elseif { [HTTP::host] ends_with "abc.com" and [HTTP::uri] starts_with "/book/catalogue" } {

      HTTP::redirect "https://uk.abc.com[HTTP::uri]" 

 

however i now need to redirect www.abc.com/book/catalogue/3333 redirects to uk.abc.com/catalogue/book/3333

 

can anyone help, give pointers how to do

1 Reply

  • Hello Mikey.

    Just try with this

    set new_uri [string map {"/book/catalogue/" "/catalogue/book/"} [HTTP::uri]]
    HTTP::redirect "https://uk.abc.com$new_uri"

    Regards,

    Dario.