Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Irule redirect on 443 VIP domain.com to www.domain.com

I think I must be missing something simple.

I have an irule setup on my port 80 vip. This works great. If I request http://domain.com/ it will redirect to https://www.domain.com/ and also if you request http://www.domain.com/ it will redirect to the https://www.domain.com/

I have a 443 VIP setup with a client side SSL profile setup that is working just fine. I want to accomplish a redirect from https://domain.com to https:/www.domain.com.

Browsing to domain.com doesn't work because the cert is only for www.domain.com.

If I apply to same Irule to the 443 VIP I just get a 404 when trying to hit the site.

Here is the Irule Below

when HTTP_REQUEST { if { (([HTTP::host] equals "domain.com") or ([HTTP::host] equals "www.domain.com")) } { HTTP::redirect "https://www.domain.com" } }

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You would not want to redirect "www.domain.com" to "https://www.domain.com"

Try this:

when HTTP_REQUEST {
  if { [string tolower [HTTP::host]] equals "domain.com" } {
    HTTP::redirect "https://www.domain.com"
    }
  }
}
0
Comments on this Answer
Comment made 04-Dec-2014 by Kevin Bozman 107
Sorry I typed that question before lunch.. I edited the original one. Issue is I want to redirect https://domain.com/ to https://www.domain.com/
0
Comment made 04-Dec-2014 by Eric
The rule that I provided should do exactly that.
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

And that should work on the 443 VIP correct? Getting ready to leave for vacation. I'll check it out when I get back.

0
Comments on this Answer
Comment made 04-Dec-2014 by shaggy 2250
it should as long as the 443 vip has a client-ssl profile and http profile assigned. make sure the 80 VIP isn't configured to redirect 80 traffic to 443 (since http-to-https redirects are the norm)
0