Skip to content

Instantly share code, notes, and snippets.

@faishal
Created April 1, 2016 15:41
Show Gist options
  • Save faishal/38ddad15d4058170d26ec81ae21967d5 to your computer and use it in GitHub Desktop.
Save faishal/38ddad15d4058170d26ec81ae21967d5 to your computer and use it in GitHub Desktop.
Force WordPress front end to http instead of https
add_action( 'template_redirect', 'wpmu_ssl_template_redirect', 1 );
function wpmu_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