SSL redirection and rewrite

I have an iRule currently in place - what we want to do is catch for a URL with a query string that a user clicks on or enters into their browser, and if that URL is accessed insecurely, we need to redirect it securely (http to https)

The URL will look similar to:

http://ourwebsite.org/login/login-page.aspx?src={3961226A-8AB0-4391-ADA1-A85AE2869824}

and needs to redirect while still keeping the query string to:

https://ourwebsite.org/login/login-page.aspx?src={3961226A-8AB0-4391-ADA1-A85AE2869824}

The only iRule that I could come up with redirects ALL http traffic, but what if I want to redirect if a user goes to /log/login-page.aspx with a query string - can I catch that one and rewrite using https while keeping the URI intact?

when HTTP_REQUEST { 
    Redirects all to HTTPS keeps URI intact 
    HTTP::redirect https://[HTTP::host][HTTP::uri] 
  }

I was thinking something like this, can anyone tell me if this would work? Would simply adding an asterisk catch any query string?

when HTTP_REQUEST {  
    switch -glob [string tolower [HTTP::uri]] {  
      "/login/login-page.aspx*" {  
        HTTP::redirect "https://ourwebsite.org[HTTP::uri]"  
      }  
    }  
  }

HTTP::uri is the path and the query string, so that should work fine.

Aaron

Thanks - can you tell me whether or not I need the asterisk?

If you’re wanting to match /login/login-page.aspx and anything after that, you’d need the asterisk. You could also use HTTP::path and not use the asterisk and -glob flag:

when HTTP_REQUEST {   
     switch [string tolower [HTTP::path]] {   
       "/login/login-page.aspx" {   
         HTTP::redirect "https://ourwebsite.org[HTTP::uri]"   
       }   
     }   
   }

Aaron

Thanks!!! You helped quite a bit!