Forum Discussion

mikeshermanit_2's avatar
mikeshermanit_2
Icon for Nimbostratus rankNimbostratus
Jan 11, 2017

iRule to add www to https traffic?

I have an iRule that looks like this:

 

when HTTP_REQUEST { if { [HTTP::host] equals "mywebsitehere.com" } { HTTP::respond 301 Location ".[HTTP::host][HTTP::uri]" } }

 

The problem is that what happens is I get http://www.mywebsitehere.com not https://www.mywebsitehere.com.

 

So my rule is adding the www which is what I want but not maintaining the https.

 

Anyone know what I'm doing wrong?

 

This rule is being applied to a VS that is listening for https traffic.

 

1 Reply

  • Your iRule looks good. I am guessing the servers have a redirect set up in such a way that when they see ";, they are redirecting to the http:// version over one or more redirects.

     

    I would recommend using CURL to identify the HTTP response to the HTTP request: https://mywebsitehere.com. Based on the redirect "Location", repeat the CURL commands to identify the subsequent responses.