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

yipeiwu_com5年前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

相关文章

PHP字符串函数系列之nl2br(),在字符串中的每个新行 (\n) 之前插入 HTML 换行符br

nl2br()定义和用法 nl2br() 函数在字符串中的每个新行 (\n) 之前插入 HTML 换行符 (<br />)。 语法 nl2br(string)参数 描述 st...

php语言流程控制中的主动与被动

这一年来,广大的phper都在辛勤劳作, 比如淘宝改版, 云计算, 腾讯开放平台, 网游, 这些作品少不了phper的功劳, 相信php语言可以继续领先行业10年, 我们憧憬未来50年,...

探讨Hessian在PHP中的使用分析

探讨Hessian在PHP中的使用分析

什么是Hessian  Hessian是由caucho提供的一种开源的远程通讯协议。  采用二进制 RPC 协议,基于 HTTP 传输,服务器端不用另开放防火墙端口。  协议的规范是公开...

使用PHP批量生成随机用户名

程序一:负责从字典中随机提取数据,写入一个新文件。(1.php) 复制代码 代码如下:<?php /* 从字典文件中提取随机值 */ $file1 =...

解决laravel 出现ajax请求419(unknown status)的问题

解决laravel 出现ajax请求419(unknown status)的问题

如下所示: 这个是因为laravel自带CSRF验证的问题 解决方法 方法一:去关掉laravel的csrf验证,但这个人不建议,方法也不写出来了。 方法二:把该接口写到api.php...