Last active
          January 12, 2018 06:23 
        
      - 
      
 - 
        
Save joshuadavidnelson/d5ded4c68e2d562a97d0 to your computer and use it in GitHub Desktop.  
    Force SSL on all pages
  
        
  
    
      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
    
  
  
    
  | <?php | |
| /** | |
| * Force SSL on all pages | |
| * | |
| * @author Joshua David Nelson, joshuadnelson.com | |
| **/ | |
| add_action( 'template_redirect', 'jdn_force_ssl' ); | |
| function jdn_force_ssl() { | |
| // force all pages to https:// | |
| if ( is_ssl() ) | |
| return; | |
| header('HTTP/1.1 301 Moved Permanently'); | |
| header("Location: https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]); | |
| exit(); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment