Created
April 1, 2016 15:41
-
-
Save faishal/38ddad15d4058170d26ec81ae21967d5 to your computer and use it in GitHub Desktop.
Force WordPress front end to http instead of https
This file contains hidden or 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
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