query($sql); if (PEAR::isError($result)) { die ($result->getMessage()); } $row = $result->fetchRow(); list($target, $mode, $type) = $row; if ($mode == 'wildcard') { $target = rtrim($target, '/'); $target .= $_SERVER['REQUEST_URI']; $target = rtrim($target, '/'); } # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html # mainly use 301 vs. 302 switch ($type) { case 300: header("HTTP/1.1 300 Multiple Choices"); break; // many representations case 301: header("HTTP/1.1 301 Moved Permanently"); break; // permanent case 302: header("HTTP/1.1 302 Found"); break; // temporary case 303: header("HTTP/1.1 303 See Other"); break; // don't cache (302 for compatibility) case 304: header("HTTP/1.1 304 Not Modified"); break; // just for caches? case 305: header("HTTP/1.1 305 Use Proxy"); break; // Location is a proxy to be used #case 306: header("HTTP/1.1 306 "); break; // reserverd case 307: header("HTTP/1.1 307 Temporary Redirect"); break; // delayed redirect? hm.. default: header("HTTP/1.1 302 Found"); break; // temporary } header("Location: $target"); ?>