We're trying to set up a proof of concept for a/b testing using htaccess on a homepage based on this gist: https://gist.github.com/iconifyit/c8d715d62b6e3960696ac1c9cbd231c5
We've modified the code to target the homepage only & it half works, meaning that it will only use the first condition & ignores the second. I'm not 100% on my htaccess rules & I've gone over this for the past couple days to figure out what is going wrong but I feel like I'm shooting at a target in the dark.
# ############################### #
# A/B TESTING (START) #
# ############################### #
# (1) Check if our cookie is already set.
# If so, redirect to the previously-viewed page.
RewriteCond %{HTTP_COOKIE} ab_test_vers=([^;]+)
RewriteRule ^/$ HTTPS://example.com/%1/$1 [cookie=ab_test_vers_match:true:example.com,L]
# (2) If no cookie is set (new visitor)
# AND the current time is on the first half of the minute
# Rewrite to /test-option-a AND set our cookie
RewriteCond %{HTTP_COOKIE} !ab_test_vers=([^;]+)
RewriteCond %{TIME_SEC} <30
RewriteRule ^/$ /even/$1 [cookie=ab_test_vers:even:example.com,L]
RedirectMatch 302 ^/$ HTTPS://example.com/welcome/
# (3) If no cookie is set (new visitor)
# AND the current time is on the second half of the minute
# Rewrite to /test-option-a AND set our cookie
RewriteCond %{HTTP_COOKIE} !ab_test_vers=([^;]+)
RewriteCond %{TIME_SEC} >29
RewriteRule ^/$ /odd/$1 [cookie=ab_test_vers:odd:example.com,L]
RedirectMatch 302 ^/$ HTTPS://example.com/about/
# ############################### #
# A/B TESTING (END) #
# ############################### #
What should be happening is that based on the time that a visitor hits the homepage of said site, they're automatically redirected to one of the two pages, in this case the pages being used for proof of concept are /welcome & /about. What's actually happening is that they're only being redirected to /welcome & the second rule is being ignored completely.