Skip to content

Instantly share code, notes, and snippets.

@jhochwald
Created July 26, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhochwald/9323d38861aeca9b35ee76c57c3b08ef to your computer and use it in GitHub Desktop.
Save jhochwald/9323d38861aeca9b35ee76c57c3b08ef to your computer and use it in GitHub Desktop.
Wordpress enforced SSL with NGINX and/or CloudFlare as reverse Proxy
<IfModule mod_rewrite.c>
RewriteEngine On
# This is needed for NGINX and CloudFlare Reverse Proxy Servers
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# This is just in case
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Here comes the redirect to SSL
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
define('WP_HOME','https://hochwald.net');
define('WP_SITEURL','https://hochwald.net');
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment