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 。
when HTTP_REQUEST {
if {[HTTP::uri] starts_with “/mvpvote”} {
pool Pool_Test.com:8080
}
}
So i would create a new pool that has the same servers but the port is 8080. I would redirect the requests to that pool. Also since i did not modify the full uri, you would need to change the path to content. (You would need to put it below mvpnote folder)
Regards
when HTTP_REQUEST {
if {[HTTP::uri] starts_with “/mvpvote”} {
pool Pool_Test.com:8080
}
}
So i would create a new pool that has the same servers but the port is 8080. I would redirect the requests to that pool. Also since i did not modify the full uri, you would need to change the path to content. (You would need to put it below mvpnote folder)
Regards
thanks ,But how to cut /mvpvote/xxxx to /xxxx
thanks ,But how to cut /mvpvote/xxxx to /xxxx
Try something like below one..
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/mvpvote"}{
set newuri [string map -nocase {"/mvpvote" ""}[HTTP::uri]]
HTTP::redirect "http://[HTTP::Host]:8080$newuri"
}
}
-Jinshu
Jinshu irule will work great but if you want the user to see the new url and add a redirect code then you might have to add a few things to it.
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/mvpvote"}{
set newuri [string map -nocase {"/mvpvote" ""}[HTTP::uri]]
HTTP::redirect "http://[HTTP::Host]$newuri"
}
}
As a quick solution, instead of cutting the url i would change the Path of content under iis or whatever web server you are using. I would add another folder named mvpvote
As a quick solution, instead of cutting the url i would change the Path of content under iis or whatever web server you are using. I would add another folder named mvpvote
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]"
}
}
}
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]"
}
}
}
Yes,this is more exactly.thank you .I will test it.
Yes,this is more exactly.thank you .I will test it.