Skip to content

Instantly share code, notes, and snippets.

@tarto-dev
Created February 3, 2015 21:12
Show Gist options
  • Select an option

  • Save tarto-dev/e8e540099fa16f91a8e0 to your computer and use it in GitHub Desktop.

Select an option

Save tarto-dev/e8e540099fa16f91a8e0 to your computer and use it in GitHub Desktop.
<?php
$protocol = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
if (substr($_SERVER['HTTP_HOST'], 0, 4) !== 'www.') {
header('Location: '.$protocol.'www.'.$_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI']);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment