https and www redirect

I am trying to figure out how to redirect the initial requests for http://sitename.com/\* and https://sitename.com/\* to גלקום – קניית דומיין ופתרונות אחסון אתרים – Your Online Presence Everything you need* 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]

}

Hi nlong,

I suppose if you have 2 virtuals you can run this irule

when HTTP_REQUEST {
   if {[HTTP::host] eq "sitename.com" } {
      HTTP::redirect "https://www.[HTTP::host]/[HTTP::uri]"
      }
}

or

when HTTP_REQUEST {
   switch -glob [HTTP::host] {
        "sitename.com" { HTTP::redirect "https://www.[HTTP::host]/[HTTP::uri]" }
     }
}

I hope this helps

Bhattman

Bhattman, unless I’m mistaken, doing [HTTP::host]/[HTTP::uri] would give you two "/"s since the “/” is part of the URI

I’d go with this:

when HTTP_REQUEST {
   if { [string tolower [HTTP::host]] eq "sitename.com" } {
      HTTP::redirect "https://www.sitename.com[HTTP::uri]"
      }
}