Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created June 12, 2023 11:14
Show Gist options
  • Save jdevalk/f1ed00e6af4867fe389afac948753849 to your computer and use it in GitHub Desktop.
Save jdevalk/f1ed00e6af4867fe389afac948753849 to your computer and use it in GitHub Desktop.
If you're not using XMLRPC, this will save tons of uncached requests to your site, assuming your homepage is cached properly.
<?php
$protocol = 'https';
if ( ! isset( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] === 'off' ) {
$protocol = 'http';
}
$url = $protocol . "://" . $_SERVER['HTTP_HOST'];
header( 'Location: ' . $url, true, 301 );
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment