Forum Discussion
nlong_67651
Nimbostratus
Sep 15, 2010https and www redirect
I am trying to figure out how to redirect the initial requests for http://sitename.com/* and https://sitename.com/* to https://www.sitename.com/* Is this easily accomplished using one irule? All SSL connections are terminating directly on the webservers, but since the initial connection to https://sitename.com is HTTP, I don't believe this matters.
I understand how to do a basic subdomain redirect, and how to redirect to https, but I'm unsure how to tie the two together. Here is the redirect I'm currently using:
when HTTP_REQUEST {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
- The_Bhattman
Nimbostratus
Hi nlong,when HTTP_REQUEST { if {[HTTP::host] eq "sitename.com" } { HTTP::redirect "https://www.[HTTP::host]/[HTTP::uri]" } }
when HTTP_REQUEST { switch -glob [HTTP::host] { "sitename.com" { HTTP::redirect "https://www.[HTTP::host]/[HTTP::uri]" } } }
- Chris_Miller
Altostratus
Bhattman, unless I'm mistaken, doing [HTTP::host]/[HTTP::uri] would give you two "/"s since the "/" is part of the URIwhen HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "sitename.com" } { HTTP::redirect "https://www.sitename.com[HTTP::uri]" } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects