//Zend_Controller_Request_Http HostName解析 const SCHEME_HTTP = 'http'; const SCHEME_HTTPS = 'https'; public function getHttpHost() { $host = $this->getServer('HTTP_HOST'); if (!empty($host)) { return $host; } $scheme = $this->getScheme(); $name = $this->getServer('SERVER_NAME'); $port = $this->getServer('SERVER_PORT'); if (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) { return $name; } else { return $name . ':' . $port; } } public function getServer($key = null, $default = null) { if (null === $key) { return $_SERVER; } return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default; } public function getScheme() { return ($this->getServer('HTTPS') == 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP; }