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

相关文章

PHP中怎样防止SQL注入分析

本文实例分析了PHP中怎样防止SQL注入。分享给大家供大家参考。具体分析如下: 一、问题描述:   如果用户输入的数据在未经处理的情况下插入到一条SQL查询语句,那么应用将很可能遭受到S...

PHP漏洞全解(详细介绍)

PHP漏洞全解(详细介绍)

针对PHP的网站主要存在下面几种攻击方式: 1、命令注入(Command Injection) 2、eval注入(Eval Injection) 3、客户端脚本攻击(Script In...

php中获取指定IP的物理地址的代码(正则表达式)

php中获取指定IP的物理地址的代码(正则表达式)

自己搭建IP数据库占资源,而且更新不便,何不使用现成的IP查询呢?下面自己写了个获取IP物理地址的PHP代码(有一定的瑕疵,请高手不吝赐教) 复制代码 代码如下: <!DOCTYP...

PHP Stream_*系列函数

PHP Stream_*系列函数

下图是对这个系列函数的思维导图——我也是第一次使用思维导图这种工具。大图在这里。其中stream_socket_*系列是PHP 5新加入的处理socket连接的函数,简单方便,下一篇博客...

PHP读取XML文件的方法实例总结【DOMDocument及simplexml方法】

本文实例讲述了PHP读取XML文件的方法。分享给大家供大家参考,具体如下: 使用DOMDocument对象读取xml 创建一个DOMDocument对象 $doc = new DOM...