Depending on your site framework, you can refer to the following:
However, as one commentor mentioned, "It is not (a) good idea because you just temporar(il)y redirect (the) user to https and (the) browser doesn't save this redirect.".
Hi Robert, thank you for your reply. I already have a http and a https version of my website, and the htaccess code to permanently redirect to the https version is ready and waiting too. I just want to run a quick test before I switch completly.
Any idea how I can best put this into an AB test using optimizely?
url targeting to substring match: www.domain.com
For the variation I added a custom redirect by adding this to the variation code:
/* _optimizely_redirect=http://https */
var oldURL = window.location.hostname + window.location.pathname;
var newURL = "https://" + oldURL;
window.location = newURL;