Created
January 28, 2017 22:00
-
-
Save DreamerKlim/0c536fdca0575fcc4956bd44deffc043 to your computer and use it in GitHub Desktop.
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
## 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