Redirect irule puts in query twice

Hi there,

I’ve got a basic irule so when someone hits my admin vhost, it will always go over https. The current rule is:

when HTTP_REQUEST {

set myURI [string tolower [HTTP::uri]]

set myQUERY [ string tolower [HTTP::query]]

if { [HTTP::host] eq “admin.mysite.com”} {

HTTP::redirect “https://admin.mysite.com[HTTP::uri][HTTP::query]”

}

}

It works fine for pages like:

http://admin.mysite.com/articles/myarticle.php

http://admin.mysite.com/articles/myarticle.php?action=view&productionarticle\_id=10080

But I’m having a problem with:

http://admin.mysite.com/charts/?selected=edit

It redirects to:

https://admin.mysite.com/charts/?selected=editselected=edit

so, it seems like it’s not parsing out the variables following the /.

Here’s a log entry of what it thought it saw:

The HTTP URI: /charts/?selected=edit -- the HTTP query: selected=edit

Any suggestions on how to get it working?

Thanks

Are you just wanting to redirect with the full URI preserved? In F5 terms, the host is the host header value, the URI is everything after the host which includes the path and the query string. The query string is everything in the URI after the question mark:

http://www.example.com:80/path/to/file.ext?param1=value1&param2=value2

HTTP::host - www.example.com:80

HTTP::uri - /path/to/file.ext?param1=value1&param2=value2

HTTP::path - /path/to/file.ext

HTTP::query - param1=value1&param2=value2

I’d guess this would work for you:

when HTTP_REQUEST {  
    
      Check if host, set to lower case, is admin.mysite.com  
     if { [string tolower [HTTP::host]] eq "admin.mysite.com"} {  
    
         Redirect client to same host and URI via https  
        HTTP::redirect "https://admin.mysite.com[HTTP::uri]"  
     }  
  }

Aaron

Ah got it. I got confused. I just need to preserve the URI and not necessarily the query.