Forum Discussion
Mukund_125243
Nimbostratus
Aug 15, 2013HTTP::redirect restrictions?
Hi,
Im trying to redirect all requests from an IP to a specific page, to a completely new URL. The redirect works but it always goes to our base domain no matter what I specify as redirect target. ...
Mark_Stradling_
Cirrus
Aug 15, 2013It sounds like you want to preserve the URI portion of the original request. If so you would want to modify it as so:
HTTP::redirect "http://www.google.com[HTTP::uri]"
I also use a little trick to ensure that I keep them on the same protocol the arrived on by doing the following:
when HTTP_REQUEST {
if {[TCP::local_port] eq 80} {
set proto "http"
}
elseif {[TCP::local_port eq 443} {
set proto "https"
}
else {
log local0. "UNKNOWN PORT!"
}
if {[HTTP::uri] contains "blah_blah_blah"} {
HTTP::redirect $proto://www.google.com[HTTP::uri]
}
}
- Mark_Stradling_Aug 15, 2013
Cirrus
Also, note that the HTTP::redirect method will issue a 302 which is "Temporarily moved." It may not be appropriate for all applications. If you need to issue a redirect for "permanently moved" you will need to do the following: HTTP::respond 301 Location "http://www.google.com[HTTP::uri]"
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