On Fri, February 15, 2008 2:46 pm, nihilism machine wrote: > this still does not work, if a domain has no preceeding www. it > redirects to http://www.www.site.com, if it has a www. it goes to > www.www.mydomain.com > , any ideas? Don't do that. Some sites may or may not use www. for whatever reason... Usually screwed-up A-name records by incompetent sysadmins, but there it is... > > <?php > > class URL { > > // Public Variables > public $ServerName; > public $WWW; > > // Public Functions > > public function __construct() { > $this->checkWWW(); > $this->ServerName = $_SERVER['SERVER_NAME'] . > $_SERVER['REQUEST_URI']; > } > > // Check if site is preceeded by 'WWW' > public function checkWWW() { > $myDomain = $_SERVER['SERVER_NAME']; > $FindWWW = 'www.'; > $POS = strpos($myDomain, $FindWWW); It won't be 1, since the http:// is in there, and even if it wasn't, it would be 0, not 1, because PHP uses 0-based strings.. > if ($POS === 1) { > $this->WWW = true; > } else { > $this->WWW = false; > } > } > > // Redirect to WWW > public function WWWRedirect() { > if ($this->WWW == false) { > $redir = "Location: http://www." . $this->ServerName; > header($redir); > } > } > > } > > $myURL = new URL(); > $myURL->WWWRedirect(); > > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php