Forum Discussion

RiverFish's avatar
RiverFish
Icon for Altostratus rankAltostratus
Jan 05, 2021

Replace path in redirect

Expectations:

using the old hostname (oldhostname.com) will redirect to the new hostname (newhostname.com)

using / (nothing after .com) will redirect to /newpath

using /oldpath/foo will redirect to /newpath/foo

The issue is the last part. If you do something like this...

when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/oldpath" } {
    HTTP::redirect "/newpath[HTTP::uri]" 
   }
 }

It grabs the oldpath, so it looks like this /newpath/oldpath. Please help if you can

  • Hello,

     

    You can try to re-create your iRule by referring below article.

     

    https://support.f5.com/csp/article/K48922683