Skip to content

Instantly share code, notes, and snippets.

@uptimizt
Created November 14, 2017 19:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uptimizt/e7842a84699066221b3f0499eaf62b40 to your computer and use it in GitHub Desktop.
Save uptimizt/e7842a84699066221b3f0499eaf62b40 to your computer and use it in GitHub Desktop.
Use HTTPS for some sites of network
<?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