Forum Discussion

dkinsler_23191's avatar
dkinsler_23191
Icon for Nimbostratus rankNimbostratus
Dec 10, 2010

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?

 

2 Replies

  • You 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"
             }
          }
       }
    }
    

    Aaron