Skip to content

Instantly share code, notes, and snippets.

@DreamerKlim
Created January 28, 2017 22:00
Show Gist options
  • Save DreamerKlim/0c536fdca0575fcc4956bd44deffc043 to your computer and use it in GitHub Desktop.
Save DreamerKlim/0c536fdca0575fcc4956bd44deffc043 to your computer and use it in GitHub Desktop.
## redirect с http на https
add_action('init', 'http_to_https_redirect');
function http_to_https_redirect(){
if( is_ssl() ) return;
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') )
wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ), 301 );
else
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment