php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com6年前PHP代码库
跳转核心代码实现。
复制代码 代码如下:

if (isset($link))
                {
                    Header("HTTP/1.1 303 See Other");
                    Header("Location: $link");
                    exit;
                }



下面是国外的一篇文章说明。
Hey Chris:
On Wed, Jan 26, 2005 at 12:28:19PM -0500, csnyder wrote:
>
> <?php
> // process form
> ...
> // redirect to results page
> header( 'HTTP/1.1 303 See Other' );
> header( 'Location: result.html' );
> exit( 'Form submitted, <a href="result.html">continue</a>.' );
> ?>
Good point. But some feedback here. The optimail syntax is:
<?php
// process form
// ...
// redirect to results page
header('Status: 303 See Other' );
header('Location: //www.jb51.net/result.html');
?>
Here's why...
Using "Status:" in the header is better because the resulting headers from
Apache are more correct:
HTTP/1.1 303 See Other
instead of
HTTP/1.1 303
Additionally, one doesn't really know which version of HTTP is being used,
so why potentially cause problems by trying to guess.
The specs say location headers must have a complete URI in them, not just
the path.
Lastly, you don't want any output after the location header.
Later,
--Dan

相关文章

WordPress的文章自动添加关键词及关键词的SEO优化

网站的关键字及网页描述关系网站对搜索引擎的友好程度,如果自己手动加显然太折腾了,那如何让wordpress博客自动为每篇文章自动关键字及网页描述。每篇文章的内容不同,我们该如何让word...

Notice: Undefined index: page in E:\PHP\test.php on line 14

治標不治本的就是將php.ini內的reporting部份修改,讓notice不顯示 error_reporting = E_ALL; display all errors, warni...

PHP实现基于图的深度优先遍历输出1,2,3...n的全排列功能

本文实例讲述了PHP实现基于图的深度优先遍历输出1,2,3...n的全排列功能。分享给大家供大家参考,具体如下: <?php $n=$_REQUEST["n"]; if...

PHP5.3安装Zend Guard Loader图文教程

PHP5.3安装Zend Guard Loader图文教程

Zend Optimizer/3.3.3 解密加代码优化,提高PHP应用程序的执行速度,显著降低服务器的CPU负载。 Zend Guard Loader/5.5.0/6.0 解密加代码优...

php基于curl重写file_get_contents函数实例

本文实例讲述了php基于curl重写file_get_contents函数。分享给大家供大家参考,具体如下: file_get_contents在连接不上的时候会提示Connection...