<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>最优良人 &#187; header</title>
	<atom:link href="http://www.zui88.com/view-tag/header/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zui88.com/blog</link>
	<description>中山php&#124;最优网络</description>
	<lastBuildDate>Mon, 13 May 2013 04:56:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>PHP利用header函数实现各种状态的跳转</title>
		<link>http://www.zui88.com/blog/view-129.html</link>
		<comments>http://www.zui88.com/blog/view-129.html#comments</comments>
		<pubDate>Mon, 15 Aug 2011 08:08:58 +0000</pubDate>
		<dc:creator>lin</dc:creator>
				<category><![CDATA[后端程序]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.zui88.com/blog/?p=129</guid>
		<description><![CDATA[header实现301永久重定向 Header("HTTP/1.1 301 Moved Permanently"); Header("Location: http://www.zui88.com"); header实现302临时重定向 Header("HTTP/1.1 302 Found"); Header("Location: http://www.zui88.com"); header实现404无法找到页面 Header("HTTP/1.1 404 Not Found"); 一下函数可实现各种状态的跳转： /** * 跳转页面 * * 使用header()进行页面跳转,不显示任何内容.如果不能使用header跳转 * @param string $url * @param int $status */ function goto($url,$status=null) { if(!empty($status)) { $status=intval($status); $codes = array( 100 =&#62; "Continue", 101 =&#62; "Switching Protocols", 200 =&#62; "OK", 201 =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>header实现301永久重定向<br />
Header("HTTP/1.1 301 Moved Permanently");<br />
Header("Location: http://www.zui88.com");</p>
<p>header实现302临时重定向<br />
Header("HTTP/1.1 302 Found");<br />
Header("Location: http://www.zui88.com");</p>
<p>header实现404无法找到页面<br />
Header("HTTP/1.1 404 Not Found");</p>
<p>一下函数可实现各种状态的跳转：</p>
<p>/**<br />
* 跳转页面<br />
*<br />
* 使用header()进行页面跳转,不显示任何内容.如果不能使用header跳转<br />
* @param string $url<br />
* @param int $status<br />
*/<br />
function goto($url,$status=null)<br />
{<br />
if(!empty($status))<br />
{<br />
$status=intval($status);<br />
$codes    = array(<br />
100 =&gt; "Continue",<br />
101 =&gt; "Switching Protocols",<br />
200 =&gt; "OK",<br />
201 =&gt; "Created",<br />
202 =&gt; "Accepted",<br />
203 =&gt; "Non-Authoritative Information",<br />
204 =&gt; "No Content",<br />
205 =&gt; "Reset Content",<br />
206 =&gt; "Partial Content",<br />
300 =&gt; "Multiple Choices",<br />
301 =&gt; "Moved Permanently",<br />
302 =&gt; "Found",<br />
303 =&gt; "See Other",<br />
304 =&gt; "Not Modified",<br />
305 =&gt; "Use Proxy",<br />
307 =&gt; "Temporary Redirect",<br />
400 =&gt; "Bad Request",<br />
401 =&gt; "Unauthorized",<br />
402 =&gt; "Payment Required",<br />
403 =&gt; "Forbidden",<br />
404 =&gt; "Not Found",<br />
405 =&gt; "Method Not Allowed",<br />
406 =&gt; "Not Acceptable",<br />
407 =&gt; "Proxy Authentication Required",<br />
408 =&gt; "Request Time-out",<br />
409 =&gt; "Conflict",<br />
410 =&gt; "Gone",<br />
411 =&gt; "Length Required",<br />
412 =&gt; "Precondition Failed",<br />
413 =&gt; "Request Entity Too Large",<br />
414 =&gt; "Request-URI Too Large",<br />
415 =&gt; "Unsupported Media Type",<br />
416 =&gt; "Requested range not satisfiable",<br />
417 =&gt; "Expectation Failed",<br />
500 =&gt; "Internal Server Error",<br />
501 =&gt; "Not Implemented",<br />
502 =&gt; "Bad Gateway",<br />
503 =&gt; "Service Unavailable",<br />
504 =&gt; "Gateway Time-out"<br />
);<br />
if (array_key_exists($status,$codes)) {<br />
$code    = $status;<br />
$msg    = $codes[$status];<br />
$status = "HTTP/1.1 {$code} {$msg}";<br />
} else {<br />
$status = null;<br />
}<br />
}<br />
if (!empty($status)) {<br />
header($status);<br />
}<br />
if(!empty($url)) {<br />
$url=url($url);header("Location: $url");<br />
if ($code==404) {<br />
echo "&lt;meta http-equiv='refresh' content='0;url=$url'&gt;";<br />
}<br />
}<br />
exit;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zui88.com/blog/view-129.html/feed</wfw:commentRss>
		<slash:comments>250</slash:comments>
		</item>
	</channel>
</rss>
