Created
July 26, 2016 20:28
-
-
Save jhochwald/9323d38861aeca9b35ee76c57c3b08ef to your computer and use it in GitHub Desktop.
Wordpress enforced SSL with NGINX and/or CloudFlare as reverse Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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