Forum Discussion

Anish_Srivastav's avatar
Anish_Srivastav
Icon for Nimbostratus rankNimbostratus
May 25, 2011

301 redirect tracking

We have a situation where we want to redirect all users hitting a virtual server to another virtual server and be able to track those redirects.

 

 

For e.g.

 

 

If a user requests ], we want to be able to redirect to ], which is easily achievable through an iRule, however is it possible to be able to pass a server variable or another method to the request so, that we are able to track somehow that the user initially requested ] and was then redirected to ?

 

 

 

Regards,

 

Anish

 

 

 

 

 

 

 

 

 

 

 

 

  • Hi Anish,

    You could either check the Referer header on the www.xyz.com.xx virtual server. Or you could append the original host and URI to the redirect as a query string parameter:

    
    when HTTP_REQUEST {
        Redirect all requests to a new URL with the host appended to the redirect
        If there is no query string already append the url parameter to the path with a ?
       if {[HTTP::query] eq ""}{
          HTTP::redirect "http://www.xyz.com.xx[HTTP::uri]?url=[HTTP::host][URI::encode [HTTP::uri]]"
       } else {
           There was a query string already so append the url parameter to the existing query string with a &
          HTTP::redirect "http://www.xyz.com.xx[HTTP::uri]&url=[HTTP::host][URI::encode [HTTP::uri]]"
       }
    }

    Aaron
  • Thanks Hoolio

     

     

    I thought about this....but, is there any other way to achieve this without using URL parameter....maybe using a cookie?

     

     

    Also, using referrer doesn't work because from what I have seen, in case of a redirect, the referrer retains the original referrer

     

     

    i.e. if someone came to www.xyz.com from a link in google, twhen he/she gets redirected to www.xyz.com.xx, the referrer retains google as value.

     

     

    Regards,

     

    Anish
  • You won't be able to set a cookie as the client is requesting to one domain and being redirected to a new domain. If the referer isn't set for this scenario, I think a query string parameter is your best option.

     

     

    Aaron