Forum Discussion
Redirect with modified Host and URI from variable
Hello, I am very new to iRules and facing an issue while trying to redirect based on the below scenario.
Trying to achieve HTTPS://mydomain1.com/"clientname" to HTTPS://demo-"clientname".mydomain2.com/"clientname"
Tried below iRule but it is not redirecting, it stays on initial request in browser.
when HTTP_REQUEST {
if { [class match [string tolower [getfield [HTTP::uri] "/" 2]] equals clientnames_dg] } {
set clientname [getfield [HTTP::uri] "/" 2] } {
HTTP::respond 301 "Location" "https://demo-${clientname}.mydomain2.com/demo-${clientname}"
}
}
1 Reply
Some correction needed in iRule. Go with this..
when HTTP_REQUEST { set clientname [string tolower[getfield [HTTP::uri] "/" 2]] if { [class match [string tolower[getfield [HTTP::uri] "/" 2]] equals clientnames_dg] } { HTTP::respond 301 Location "https://demo-$clientname.mydomain2.com/$clientname" } }
Thanks
Recent Discussions
Related Content
* 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