Forum Discussion
RiverFish
Jan 05, 2021Altostratus
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 t...
- Jan 05, 2021
Hello,
You can try to re-create your iRule by referring below article.
https://support.f5.com/csp/article/K48922683
Mayur_Sutare
MVP
Hello,
You can try to re-create your iRule by referring below article.
https://support.f5.com/csp/article/K48922683
RiverFish
Jan 05, 2021Altostratus
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
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects