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

相关文章

修改Laravel5.3中的路由文件与路径

前言 大家可能没有注意到, 在 Laravel 4 以及更老版本中, 路由逻辑是性能上的一个瓶颈--特别是对于有很多路由定义的应用而言. 一个只有几百条路由定义的 Laravel 站点...

PHP如何将XML转成数组

如果你使用 curl 获取的 xml data xml=simplexmlloadstring(data); data[′tk′]=jsondecode(jsonencode(xml),...

MyEclipse常用配置图文教程

MyEclipse常用配置图文教程

  MyEclipse有很多功能,但是我们经常用到的功能其实并不是特别多,在这里将一些有用的小技巧记录下来,作为备忘录,同时也希望能够对他人有些许帮助吧。 一 工作组(working s...

PHP与SQL注入攻击[三]

这几天太忙,继续连载哈哈,争取半个月结束。 上文说到数据库自带的不安全输入过滤功能,但这样的功能不是所有数据库都有的。目前大概只有MySQL,SQLite,PostgreSQL,Syba...

PHP+Ajax简单get验证操作示例

PHP+Ajax简单get验证操作示例

本文实例讲述了PHP+Ajax简单get验证操作。分享给大家供大家参考,具体如下: 1、显示页面代码 index.html <!DOCTYPE html> <htm...