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的AES加密算法完整实例

本文实例讲述了PHP的AES加密算法。分享给大家供大家参考,具体如下: <?php class MCrypt { private $hex_iv = '000000...

php格式输出文件var_export函数实例

本文实例讲述了php格式输出文件var_export函数的用法。分享给大家供大家参考。具体如下: var_export:php 4 >= 4.2.0, php 5 var_expo...

Laravel网站打开速度优化的方法汇总

Laravel网站打开速度优化的方法汇总

前言 Laravel是一个功能强大的框架,组件很多,代码也很庞大,它的易用方便是牺牲了性能的,即便如此它仍然是一个优秀的框架,但在正式环境下要做好优化提升网站的打开速度。下面这篇文章主要...

解析在PHP中使用全局变量的几种方法

简介即使开发一个新的大型PHP程序,你也不可避免的要使用到全局数据,因为有些数据是需要用到你的代码的不同部分的。一些常见的全局数据有:程序设定类、数据库连接类、用户资料等等。有很多方法能...

php木马攻击防御之道

1、防止跳出web目录   首先修改httpd.conf,假如您只允许您的php脚本程式在web目录里操作,还能够修改httpd.conf文档限制php的操作路径。比如您的web目录是/...