Forum Discussion
dkinsler_23191
Dec 10, 2010Nimbostratus
problem with HTTP::redirect
Hi all, I am trying to do a redirect but I am getting a strange result. My code looks like this....
when HTTP_REQUEST {
if { ([HTTP::host] equals "abc.com") and ([HTTP::uri] equals "/enroll")} {
HTTP::redirect "www.xyz.com/test/enrollment/home.aspx"
}
if { ([HTTP::host] equals "www.abc.com") and ([HTTP::uri] equals "/enroll")} {
HTTP::redirect "www.xyz.com/test/enrollment/home.aspx"
}
}
But the result I am getting on the redirect is. (from httpwatch)
Redirect A redirect to http://abc.com/www.xyz.com/test/enrollment/home.aspx was issued by the server
I have also tried changing HTTP::redirect "www.xyz.com/test/enrollment/home.aspx" to
HTTP::respond 301 Location "www.xyz.com/test/enrollment/home.aspx"
but basically get the same thing. Any ideas why I keep getting the "abc.com before the URL I want to redirect to?
- hooleylistCirrostratusYou need to specify a fully qualified URL in redirects in this situation. Else, the browser interprets the Location in the redirects as local and appends it to the current host. Can you try this?
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "abc.com" - "www.abc.com" { Request to abc.com or www.abc.com. Check for URI of /enroll if {[HTTP::uri] equals "/enroll"}{ HTTP::redirect "http://www.xyz.com/test/enrollment/home.aspx" } } } }
- dkinsler_23191NimbostratusThanks Hoolio, I dont know how I missed that!
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