Forum Discussion

DM_5174's avatar
DM_5174
Icon for Nimbostratus rankNimbostratus
May 09, 2011

HTTP to HTTPS conditional redirect help

hi all,

 

 

Please help with integrating the first code and second code int an effcient script that achieve both redirecting if the

 

users comes in connecting to www.test.com so it goes to another URL that is HTTPS, and also if I come in

 

on this virtual server other than www.test.com should get the normal http-to-https default redirect.

 

 

Thanks for your help!

 

 

 



when HTTP_REQUEST {       
     Check if requested domain is www.test.com       
    if {[string tolower [HTTP::host]] eq www.test.com}{                    
         Redirect client to https 
         HTTP::redirect ]           
         } 
} 

 

 

**** We need also need to add the default for any request to this Virtual server so it can redirect to all connections from HTTP to HTTPS

 

 



when HTTP_REQUEST {    
HTTP::redirect https://[HTTP::host][HTTP::uri] 
} 

 

2 Replies

  • Hi DM,

    I believe that this will do what you are needing.

    
    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] eq "www.test.com" } {
    HTTP::redirect "https://www.test.123.com/[HTTP::uri]"
    return
    }
    else {
    HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::uri]"
    }
    }