Making WordPress.org

Changeset 1546


Ignore:
Timestamp:
05/06/2015 02:48:49 PM (11 years ago)
Author:
kovshenin
Message:

WordCamp.org: Force HTTPS on all WordCamp sites that support it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/ssl.php

    r1524 r1546  
    113113                define( 'DONOTCACHEPAGE', true );
    114114});
     115
     116/**
     117 * Force HTTPS on all WordCamp.org sites that support it.
     118 */
     119function wcorg_force_ssl() {
     120    if ( php_sapi_name() == 'cli' || is_ssl() )
     121        return;
     122
     123    // Our SSL certificate covers only *.wordcamp.org but year.city.wordcamp.org rediercts should still work.
     124    if ( ! preg_match( '#^(?:[^.]+\.)?wordcamp\.org$#i', $_SERVER['HTTP_HOST'] ) )
     125        return;
     126
     127    header( 'Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], true, 301 );
     128    exit;
     129}
     130
     131add_action( 'muplugins_loaded', 'wcorg_force_ssl' );
Note: See TracChangeset for help on using the changeset viewer.