Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohsinworld/80eb8c2bf0575383c7beea78d2ac88ae to your computer and use it in GitHub Desktop.
Save mohsinworld/80eb8c2bf0575383c7beea78d2ac88ae to your computer and use it in GitHub Desktop.
add_action( 'template_redirect', 'bhww_ssl_template_redirect', 1 );
function bhww_ssl_template_redirect() {
if ( is_ssl() && ! is_admin() ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
exit();
} else {
wp_redirect( 'http://' . $_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