https forced redirect question
| From: | nihilism machine | Date: | Fri, 15 Feb 2008 19:58:54 +0000 |
| Subject: | https forced redirect question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-269373@lists.php.net to get a copy of this message | ||
why isnt this redirecting my page to https://www.mydomain.com instead the page stays at my domain.com
<?php
class URL {
// Public Variables
public $HTTPS;
public $ServerName;
public $WWW;
// Public Functions
public function __construct() {
$this->checkHTTPS();
$this->checkWWW();
$this->ServerName = $_SERVER['SERVER_NAME'];
}
// Check if HTTPS
public function checkHTTPS() {
if ($_SERVER['HTTPS'] != "on") {
$this->HTTPS = false;
} else {
$this->HTTPS = true;
}
}
// Redirect to HTTPS Site
public function HTTPSRedirect() {
if($this->HTTPS = false) {
$redir = "Location: https://" . $_SERVER['SERVER_NAME'];
echo $redir;
header($redir);
}
}
// Check if site is preceeded by 'WWW'
public function checkWWW() {
return true;
}
// Redirect to WWW
public function WWWRedirect() {
if ($this->WWW = false) {
$redir = "Location: http://www." . $_SERVER['SERVER_NAME'];
header($redir);
}
}
}
$myURL = new URL();
$myURL->HTTPSRedirect();
?>