Re: www. check still not working
| From: | nihilism machine | Date: | Fri, 15 Feb 2008 21:04:32 +0000 |
| Subject: | Re: www. check still not working | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269385@lists.php.net to get a copy of this message | ||
thank you everyone!
On Feb 15, 2008, at 3:53 PM, Nathan Rixham wrote:
Anjan Upadhya wrote:// Redirect to WWW public function WWWRedirect() {and public function checkWWW() { $this->WWW = (strtolower(trim(substr($_SERVER['SERVER_NAME'],0,4))) == 'www.'); } --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpif ($this->WWW == false) { $redir = "Location: http://www." . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; header($redir); }} Regards, Anjan Upadhya nihilism machine wrote:<?php class URL { // Public Variables public $HTTPS; public $ServerName; public $WWW;// Public Functions public function __construct() { $this->checkWWW();}// Check if site is preceeded by 'WWW'public function checkWWW() {$myDomain = $_SERVER['SERVER_NAME']; $FindWWW = 'www.'; $POS = strpos($myDomain, $FindWWW); if ($POS === 1) { $this->WWW = true; } else { $this->WWW = false; }} // Redirect to WWW public function WWWRedirect() {if ($this->WWW = false) { $redir = "Location: http://www." . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; header($redir); }} } $myURL = new URL(); $myURL->WWWRedirect(); ?>