04-Jan-2021
16:14
- last edited on
04-Jun-2023
21:07
by
JimmyPackets
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
Solved! Go to Solution.
04-Jan-2021 22:13
Hello,
You can try to re-create your iRule by referring below article.
https://support.f5.com/csp/article/K48922683
04-Jan-2021 22:13
Hello,
You can try to re-create your iRule by referring below article.
https://support.f5.com/csp/article/K48922683
05-Jan-2021
11:35
- last edited on
04-Jun-2023
21:07
by
JimmyPackets
Mayur, we eventually found that article and were able to come up with the irule below which got us working. The switch statement is just some tweaks that are custom for our particular site. Thanks!
when HTTP_REQUEST {
if { [HTTP::host] contains "oldhostname.com" } {
set newhost "newhostname.com"
set newpath [string map {"/oldpath/" "/newpath/"} [HTTP::uri]]
HTTP::redirect "https://$newhost$newpath"
return
} else {
switch [HTTP::uri] {
"/" -
"/oldpath" -
"/oldpath/" -
"/oldpath/login/" -
"/newpath/login/" { HTTP::redirect "https://[HTTP::host]/newpath/login" }
default {}
}
return
}
}