Forum Discussion

jacob900_39797's avatar
jacob900_39797
Icon for Nimbostratus rankNimbostratus
May 07, 2007

mutliple redirect with uri insertion

I need some help doing a multiple http-tohttps redirect with uri inserstion. I have been working with test script..unsucessfully so far.

 

when HTTP_REQUEST {

 

if {[HTTP::host] eq "app1.abc.com/"}{

 

HTTP::redirect https://company.abc.com/app1

 

}

 

elseif

 

{[HTTP::host] eq "app2.abc.com/"}{

 

HTTP::redirect https://company.abc.com/app2

 

}

 

elseif

 

{[HTTP::host] eq "app3.abc.com/"}{

 

HTTP::redirect https://company.abc.com/app3

 

}

 

}

 

 

Goals: redirect these links and add the uri...

 

app1.abc.com > https://www.company.com/app1

 

app2.abc.com > https://www.company.com/app2

 

app3.abc.com > https://www.company.com/app3

 

 

Any help is defintely appreciated.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    HTTP::host is the host of the request (like app1.abc.com or www.company.com). It wouldn't include any portion of the URI like the forward slash you have included. HTTP::uri would be the URI, including the query string.

    So if you want to redirect all requests via HTTP to HTTPS you can remove the trailing forward slash on the HTTP::host comparison. For example:

    
    ...
     if {[HTTP::host] eq "app1.abc.com"}{
    ...

    You can add logging statements to see exactly what is being parsed:

    
    log local0. "\[HTTP::host\]: [HTTP::host]; \[HTTP::uri\]: [HTTP::uri]"

    Aaron