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实现发送微信模板消息的方法

本文实例讲述了php实现发送微信模板消息的方法。分享给大家供大家参考。具体如下: 该方法基于thinkphp实现实现,具体OrderPush.class.php文件如下: 复制代码 代码...

php事务处理实例详解

一、php事务处理概述: 事务:是若干事件的集合 事务处理:当所有事件执行成功,事务才执行;若有任何一个事件不能成功执行,事务的其它事件也不被执行。 只要你的MySQL版本支持BDB或I...

PHP提示Cannot modify header information - headers already sent by解决方法

本文实例讲述了PHP提示Cannot modify header information - headers already sent by解决方法,是进行PHP程序设计过程中经常会遇到...

php 文件上传系统手记

整个系统只有带码全部用PHP,没有JS,没有正则...纯纯的PHP...其实别的我也不会呵呵... 下面是原表单的html带码... 上传文件表单 复制代码 代码如下: <form...

PHP的Json中文处理解决方案

本文讲述了PHP的Json中文处理解决方案。分享给大家供大家参考,具体如下: Json是现在被广泛使用的用于传递字符串的格式,相比xml更显得简单易懂以及更方便操作,php下就俩个函数,...