Forum Discussion

trx's avatar
Jan 19, 2011

[HTTP::uri] in browser URL

Hello Community,

Does anyone know how the first condition can remain true until the URL IN THE BROWSER changes, making it false?

 

 

 

when HTTP_REQUEST {

 

if { ([string tolower [HTTP::uri]] contains "xyz") } {

 

 

HTTP::respond 301 Location https://[HTTP::host][HTTP::uri]

 

// Currently all the request URLs calls from the page get redirected to "http" because they are considered an independent

 

// URI request.

 

// Goal is to have all request URLs calls from the page to remain https because the URI in the browser remains true.

 

} else {

 

HTTP::respond 301 Location http://[HTTP::host][HTTP::uri]

 

}

 

}

 

 

 

 

 

 

 

Any direction is fully appreciated.

 

 

 

Regards,

 

TRX

 

5 Replies

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Trx,

     

     

    That iRule would check to see if the path or query string contained the string xyz and redirect the request to the same host and URI via HTTPS.

     

     

    Can you clarify your question? Is the issue related to something with a page that references other objects and only some requests should be redirected?

     

     

    Aaron
  • Sorry for not being clear. Here is an example.

     

     

    Go to http://www.qad.com/partnercenter

     

     

    IRules will route traffic over https if browser URL shows "template.LOGIN" else route over "http".

     

     

    ex)

     

     

    when HTTP_REQUEST {

     

    if { ([string tolower [HTTP::uri]] contains "/template.login") } {

     

    Do nothing. Let traffic go through because these need to go over SSL

     

    return

     

    } else {

     

    else re-route traffic back to http from https

     

    HTTP::respond 301 Location http://[HTTP::host][HTTP::uri]

     

    return

     

    }

     

    }

     

     

    Know that the URL will show "https://www.qad.com/partnercenter", but all the href on that page will go over "http" if the URL does NOT contain "template.LOGIN".

     

    Resulting in http/https mixture pop ups on IE8/windows 7 on an ssl page URL.

     

     

    So the question is, is there a way to keep all page href request urls to go over https as long as the browser URL contains "template.LOGIN" so we can avoid SSL http/https prompts?

     

     

    Hope that helps.

     

     

    Thanks.

     

     

    Regards,

     

    TRX
  • NOTE: The prompts occur before the site is redirect to "login.qad.com...".
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    As a bit of a guess, can you try this?

    
    when HTTP_REQUEST {
       if { ([string tolower [HTTP::uri]] contains "/template.login") or ([string tolower [HTTP::header Referer]] contains "/template.login") } {
           Do nothing. Let traffic go through because these need to go over SSL
          return
       } else {
           else re-route traffic back to http from https
          HTTP::respond 301 Location http://[HTTP::host][HTTP::uri]
          return
       }
    }
    

    Aaron
  • Thanks.

     

     

    The solution I went with was just redirecting back to http after the credentials URL post has been sent to the

     

    server. I did that by setting a flag to 0 and after the post URL was sent the flag is set to 1. Next request if the

     

    flag is set to 1, then route back to http.

     

     

     

    Regards,

     

    TRX