Background
I've managed to get http to https redirection working for my Wordpress installation by including this snippet in my .htaccess
file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
I'm running in the Google Cloud environment and the problem is that the health check requires that the "health checked resource" returns 200 OK
. The health check issues an HTTP request without the X-Forwarded-Proto
header set so Apache will respond with a 301
and thus the health check fails (it doesn't follow redirects). Unfortunately it's not possible to define headers in the Google Health Checker so I can't fake the X-Forwarded-Proto
header to "https". So my hope for a workaround would be to supply a query parameter in the health check path and configure the .htaccess
file to ONLY redirect if the specified query param is undefined (or equal to false or something similar).
Question
How can I modify the RewriteCond
(I presume) to only perform redirection if the X-Forwarded-Proto
header is not equal https
(as in the example above) AND the query string does not contain the parameter healthCheck=true
?