Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created November 15, 2011 04:21
Show Gist options
  • Save ctrl-freak/1366127 to your computer and use it in GitHub Desktop.
Save ctrl-freak/1366127 to your computer and use it in GitHub Desktop.
Redirect Specific URLs to HTTPS
<?
if (in_array($url_parts[0], array('admin','application','login')) && $_SERVER['SERVER_PORT'] != '443') {
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
exit();
} else if (!in_array($url_parts[0], array('admin','application','login')) && $_SERVER['SERVER_PORT'] == '443') {
header('Location: http://'.$_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