It works on our home page. so if you go to www.domain.com or http:// www.domain.com it will force you to https://. So that works.
But if you go directly to http:// www.domain.com/about-us it won't force you back to https. If you go to https:// www.domain.com/about-us it works fine. But You have to manually put the 's' in.
I'm running the 'Wordpress HTTPS (SSL)' plugin.
In my htaccess I have:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
And in my wp-config I have:
define('WP_HOME','https://www.domain.com');
define('WP_SITEURL','https://www.domain.com');
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
EDIT WITH SOLUTION
I'm not going to mark this as solved since I don't know why this solution worked for me, as the code should actually work the way I have it based on everything I've read from here and from Amazon concerning their ELBs. The important thing to remember that the X-Forwarded-Proto is the key here and is the header passed through the ELB. https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/
I ended up moving the RewriteCond & RewriteRule from the .htaccess to my .conf file and everything is working now as expected.
.htaccess
CODE from here: wordpress.stackexchange.com/a/256042/110572 and remove theif (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
CODE from yourwp-config.php
.$_SERVER['HTTP_X_FORWARDED_PROTO']
may not even be set. Check withisset( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
in the if condition first.http://www.ex.com to https://ex.com
. We'd like to keep it at www, but also we haveqa.ex.com
for testing. Right now it strips of the "qa" and redirects tohttps://ex.com
. All the https is working on the back end just still not redirectinghttp://qa.ex.com/about to https://qa.ex.com/about