Forum Discussion
yet another redirect question
so heres my question. i have a simple irule that will redirect to a new host/uri based on the incoming request. however what i'm discovering is that apparently its not as simple as i had originally thought. i dont seem to understand why the orignial URI still gets appended to the redirected uri..
when HTTP_REQUEST {
set dest https://some.host.com/singleuri
switch -glob [string tolower [HTTP::host][HTTP::uri]] {
"some.other.host.com/anotheruri/*" {
HTTP::respond 301 Location "$dest[HTTP::uri]"
}
}
}
this works, yet the new uri contains "/singleuri/anotheruri/".. what am I doing wrong?
- omniplex
Nimbostratus
You are appending the previous URI which is contained in the [HTTP::uri] variable. - What_Lies_Bene1
Cirrostratus
You'd want something like this;when HTTP_REQUEST { switch -glob [string tolower [HTTP::host][HTTP::uri]] { "https://some.host.com/singleuri*" { HTTP::respond 301 Location "https://some.other.host.com/anotheruri/" } } }
- Michael_Yates
Nimbostratus
Hi Dave,when HTTP_REQUEST { switch -glob [string tolower [HTTP::host][HTTP::uri]] { "some.host.com/singleuri*" { HTTP::respond 301 Location "https://some.other.host.com[string map {"/singleuri" "/anotheruri"} [HTTP::uri]]" } } }
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