Forum Discussion

Michael_107360's avatar
Nov 18, 2013

HTTP2HTTPS not working for ROOT with no URI

everything is working except 2 items: www.website.com does NOT redirect to https (root url with NO URI) and www.website.com/Quicken does not redirect to https:

 

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/default-client.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/american-express-gold-card.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/ameriprise-mastercard.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/ameriprise-world-elite-mastercard.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/ameriprise-world-mastercard.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/platinum-card-from-american-express.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/client-login" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/client-login/esignature.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/client-login/logout.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/client-login/message-center/retrieve.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/Quicken" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] contains "/default.asp" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } elseif { [string tolower [HTTP::uri]] equals "" } { log local0. "redirect www.website.com" HTTP::redirect https://[HTTP::host][HTTP::uri] } }

 

1 Reply

  • Try this:

    when HTTP_REQUEST { 
        if { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/default-client.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards /american-express-gold-card.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards /ameriprise-mastercard.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/ameriprise-world-elite-mastercard.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/ameriprise-world-mastercard.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/cash-cards-and-lending/cards/platinum-card-from-american-express.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/client-login" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/client-login/esignature.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/client-login/logout.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/client-login/message-center/retrieve.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/quicken" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] contains "/default.asp" } { 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } elseif { [string tolower [HTTP::uri]] equals "/" } { 
            log local0. "redirect www.website.com" 
            HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } 
    }
    

    There were two significant issues:

    1. A URI will ALWAYS contain at least the forward slash, so if the user enters no URI in the browser, it will equals "/".

    2. You're doing to a [string tolower ] evaluation for "Quicken", but your string is not completely lowercase.