Forum Discussion

charlestips_149's avatar
charlestips_149
Icon for Nimbostratus rankNimbostratus
Jun 30, 2010

http to https redirect except for specific URL

We currently have a wildcard cert and virtual server setup so that anyone trying to go to http://www.domain.com/directory gets redirected to https://www.domain.com/directory simple enough

 

 

what we would like to do is not redirect for a specific directory.

 

 

So redirect for all parts of www.domain.com unless a user goes to http://www.domain.com/specialdirectory

 

 

How can I modify the standard http to https irule for that, or should there be a specific irule added for just this.

 

 

 

11 Replies

  • You could do it this way:

    
    when HTTP_REQUEST {
    if { [HTTP::host] equals "www.domain.com" } {
    if { [string tolower [HTTP::uri]] starts_with "/directory" } {
    pool pool.of.servers.to.service.request
    }
    else {
    HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
    }
    }
    

    If the Virtual Server is only used to service things for "www.domain.com" then you could clean it up even more:

    
    when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] starts_with "/directory" } {
    pool pool.of.servers.to.service.request
    }
    else {
    HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
    }
    }