Forum Discussion

benbenben_9082's avatar
benbenben_9082
Icon for Nimbostratus rankNimbostratus
Mar 07, 2007

Redirects + keeping headers

What I am trying to do may seem a little weird...

 

 

Basically I am trying to capture the URL a client is visiting into a header which works fine. I then need to redirect the client to a specific webpage which of course breaks the header insert.

 

 

I've tried using the 'use pool' option within my iRule which retains the header however this will not accommodate the redirect I need.

 

 

when HTTP_REQUEST {

 

set host [HTTP::host]

 

set path [HTTP::uri]

 

HTTP::header insert "test" http://$host$path

 

}

 

 

Can anyone give any clues as to how I can include a redirect to a specific URL whilst retaining the header 'test'?

 

 

Thanks in advance!

 

 

Ben

 

2 Replies

  • Hi,

    You can use HTTP::respond to include a header name and value in the redirect:

    HTTP::respond 302 Location http://www.example.com/ Header_Name Header_Value

    So:

    
    when HTTP_REQUEST {
       if {$some_condition==1}{
          HTTP::respond 302 Location http://www.example.com/ test_header_name "[HTTP::host][HTTP::uri]"
       }
    }

    Aaron
  • Thanks for all your help so far, unfortunately that 'respond' directive didn't help.

     

     

    What I am trying to do is insert the header and redirect to a php script that reads the custom header. Hope this makes our intentions a bit clearer?

     

     

    Thanks