Created
May 29, 2025 14:35
-
-
Save currentcreative/55256acb7a4162dae64e00aeb4877800 to your computer and use it in GitHub Desktop.
Force SSL in WordPress wp-config.php
This file contains hidden or 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
Just add this to wp-config.php at the top if changing URLs in Settings > General from http to https breaks website: | |
// REWRITE TO FORCE HTTPS TO WORK: | |
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') | |
$_SERVER['HTTPS']='on'; | |
I used this on 5/28/25 and it worked perfectly. | |
I got it from this answer here from 2015 and it still works fine in 2025: | |
https://stackoverflow.com/a/32430896/2917251 | |
answered Sep 7, 2015 at 3:59 | |
user3094069: | |
"i used this one. which is fine to go on. | |
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') | |
$_SERVER['HTTPS']='on'; | |
if your server port is differed from 443. you can specify it . Otherwise, no need to use it once again ." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment