WordPress HTTPS

So, if you’ve got a WordPress blog and you want to access it via HTTP and HTTPS then you might notice that when using the HTTPS version all the links (and form actions) are set to use the HTTP version. Thanks to a little help from a plugin and Paul Bain we came up with a solution of putting this into the wp-config.php file:

if( $_SERVER['HTTPS'] ) {
    define('WP_HOME', preg_replace('/^http/', 'https', WP_HOME));
    define('WP_SITEURL', preg_replace('/^http/', 'https', WP_SITEURL));
}

Seems to work pretty well!

2 Comments »

  1. Hey… That’s really handy! I run a blog (http://www.thecoverups.co.uk/wedding-band-function-band/wedding-band-blog/) and I can imagine there being occasions when running with HTTPS would be handy. Cheers for the tip!

    Comment by Mike — April 19, 2011 @ 5:36 pm

  2. Please help cannot find the answer to this….

    I have a multi site install running two separate networks..

    The first domain domain1.com has a ssl cert on it
    The second domain domain2.com does not..

    I want to force the home and site url of all newly created blogs on domain1.com to get prefixed with https… I need to separate this so it does not affect domain2.com at all…

    i am using this for the login and admin area
    if ( $_SERVER["HTTP_HOST"] == “domain1.com” ) {
    define(‘FORCE_SSL_ADMIN’, true);
    }

    but i cannot figure out what to do for force dynamically all new blogs that get create in domain1.com to get the https prefix automatically

    Thanks Scott

    Comment by Scott — November 13, 2011 @ 2:31 pm

RSS feed for comments on this post.  | TrackBack URL

Leave a comment