Forum Discussion
denny_65237
Nimbostratus
Oct 19, 2016HTTP Redirect and cut out URL
client request contain url "mvpvote",for example,request http://www.test.com/mvpvote/xxxxx,I want redirect URL to http://www.test.com:8080/xxxxx, I don't how 。
Vernon_97235
Oct 19, 2016Historic F5 Account
There are two drawbacks with the use of
string map, in this case. Firstly, it will replaces all instances of "/mvpvote", even if it happens more than once in the path (or if you're using HTTP::uri, in the entire length of the Request Target). Secondly, it would replace, for example, "/mvpvote2/" with "2/".
The following solution should be more correct, and as a bonus, better performing (though not tested!):
when HTTP_REQUEST {
switch -glob [HTTP::path] {
"/mvpvote" {
HTTP::respond 301 Location "http://[HTTP::host]/[HTTP::query]"
}
"/mvpvote/*" {
HTTP::respond 301 Location "http://[HTTP::host][substr [HTTP::uri] 8]"
}
}
}
- denny_65237Oct 20, 2016
Nimbostratus
Yes,this is more exactly.thank you .I will test it.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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