Forum Discussion
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
- Kevin_Stewart
Employee
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:
-
A URI will ALWAYS contain at least the forward slash, so if the user enters no URI in the browser, it will equals "/".
-
You're doing to a [string tolower ] evaluation for "Quicken", but your string is not completely lowercase.
-
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com