Forum Discussion

DM_5174's avatar
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 so it goes to another URL that is HTTPS, and also if I come in


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



Thanks for your help!




when HTTP_REQUEST {       
     Check if requested domain is       
    if {[string tolower [HTTP::host]] eq}{                    
         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 "" } {
    HTTP::redirect "[HTTP::uri]"
    else {
    HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::uri]"