Forum Discussion

elvisc_26948's avatar
elvisc_26948
Icon for Nimbostratus rankNimbostratus
Jan 06, 2010

redirect/return a diff url without client action

Is there a way to return/redirect a different URI back to client but without aborting the session i.e no client action required.

 

 

eg:

 

http:xyz.com/URI_1

 

 

http request {

 

return/redirect (but completely transparent to client):

 

http://xyz.com/URI_2

 

}

 

 

next http request event:

 

[host::uri] should show --> http://xyz.com/URI_2
  • Hi Elvisc,

    if I understand you correctly you could do the following:

     
     when HTTP_REQUEST { 
       if { [HTTP::uri] eq "/uri_1" } { 
          HTTP::uri /prefix[HTTP::uri] 
          } 
     } 
     

    This would change the URI w/o the client ever seeing the change in the URI

    Was this what you were looking for?

    Bhattman
  • thanks for the quick response... I have tried a few other methods including yours before... which basically replace the uri from LB to the server side.

     

     

    What I really want to achieve is:

     

    eg the sequence of requests looks like this:

     

    http://xyz.com/URI_1

     

    http://xyz.com/URI_2

     

    "

     

    "

     

    http://xyz.com/URI_X

     

    http://xyz.com/index

     

    http://xyz.com/URI_1

     

    "

     

    "

     

    http://xyz.com/URI_X

     

    http://xyz.com/index

     

    "

     

    "

     

    I want to always capture at the point where index request comes in first before I read

     

    the URIs.

     

     

    ---------------------------------------------------

     

    Currently I am trying to do it using this technique:

     

    when RULE_INIT {

     

    global var so all subsequent sessions can check if index is requested first

     

    set ::INDEX_READ "TRUE"

     

    log local0. "RULE INIT ==> $::INDEX_READ"

     

    }

     

     

    when HTTP_REQUEST {

     

    if (http::uri is index) and (INDEX_READ is FALSE) {

     

    do something URI manipulation

     

    set ::INDEX_READ "FALSE"

     

    }

     

    if (INDEX_READ is FALSE) {

     

    if { [HTTP::uri] eq "/URL_1" } {

     

    do something other string manipulation

     

    HTTP::uri /prefix[HTTP::uri]

     

    }

     

    }

     

    }

     

     

    Trying that now and will let you know how it goes...

     

     

     

     

     

  • Adding another side question to my previous response...

     

     

    when I do:

     

     

    HTTP::path [string map ch1 ch4" [HTTP::path]]

     

    log local0. "========>> HTTP_Path: [HTTP::path] HTTP_URI:"

     

     

    output:

     

    ========>> HTTP_Path: path/path/ch1/file

     

     

    I am still seeing ch1 in the output....Shouldn't it print out ch4 instead?