-
-
Save uptimizt/e7842a84699066221b3f0499eaf62b40 to your computer and use it in GitHub Desktop.
Use HTTPS for some sites of network
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
<?php | |
/** | |
* Use HTTPS for some sites of network | |
*/ | |
function rsssl_check_protocol_multisite($url, $scheme, $orig_scheme){ | |
if(get_current_blog_id() == 23){ | |
$url = str_replace("http://", "https://", $url); | |
} | |
return $url; | |
} | |
add_filter("set_url_scheme", "rsssl_check_protocol_multisite", 20, 3 ); | |
function forect_https_redirect(){ | |
if(get_current_blog_id() != 23){ | |
return; | |
} | |
$use_sts = true; | |
if ($use_sts && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { | |
header('Strict-Transport-Security: max-age=31536000'); | |
} elseif ($use_sts) { | |
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301); | |
die(); | |
} | |
} | |
add_action('ínit', 'forect_https_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment