Skip to content

Instantly share code, notes, and snippets.

@rickard2
Created November 2, 2012 08:50
Show Gist options
  • Save rickard2/3999571 to your computer and use it in GitHub Desktop.
Save rickard2/3999571 to your computer and use it in GitHub Desktop.
https wp
<?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