I run a Wordpress behind a other (main) webserver. The main Server does have a rule to redirect all requests to /wpa to the Wordpress Server with a ProxyPass
ProxyPass /wpa/ http://vm.example.com/wpa/
ProxyPassReverse /wpa/ http://vm.example.com/wpa/
Wordpress itself comes with this .htaccess file at the Wordpress root:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpa/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpa/index.php [L]
</IfModule>
Everything is working fine with http. But I want to switch to https and this is a problem. The SSL termination is done at a Load Balancer.
The thing is, that all traffic behind the Load Balancer is non-ssl. If I change the Wordpress homeurl and siteurl from http to https, I get a redirect error (loop).
I tried to use a rule like this at the main server:
RewriteCond %{HTTPS} !=on
RewriteRule ^/wpa/(.*)$ https://www.example.com/wpa/$1 [L,R=301]
Still get a redirect error. I tried to check RewriteLog but I failed finding the right information.
Does anyone have a clue how to fix this?
Use the below code in wp-config.php
,
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';
Check your .htaccess
file; it should be clean.
Re-save the permalink.
If using a CDN, enable 443 port.