Skip to main content
edited with solution
Source Link

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:// http://www.domain.com/about-us it won't force you back to https. If you go to https:// https://www.domain.com/about-uswww.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.

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';

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.

Source Link

Forcing HTTPS with Wordpress on AWS

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';