Created
November 2, 2012 08:50
-
-
Save rickard2/3999571 to your computer and use it in GitHub Desktop.
https wp
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 | |
/* | |
Plugin Name: HTTPS everywhere | |
Plugin URI: http:// | |
Description: HTTPS everywhere | |
Author: Rickard Andersson | |
Version: 1.0 | |
Author URI: http://0x539.se/ | |
*/ | |
function https_everywhere() { | |
if ($_SERVER['HTTPS'] != "on" && !isset($_SERVER['SPDY_VERSION']) ) { | |
$dst = sprintf("https://%s%s", $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']); | |
wp_redirect($dst, 301); | |
die(); | |
} else { | |
header("Strict-Transport-Security: max-age=500"); | |
header("X-Content-Type-Options: nosniff"); | |
header("X-Frame-Options: SAMEORIGIN"); | |
// if IE | |
header("X-UA-Compatible: IE=edge,chrome=1"); | |
header("X-XSS-Protection: 1; mode=block"); | |
// endif | |
} | |
} | |
add_action("init", "https_everywhere"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment