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中session过期时间设置及session回收机制介绍

网上很多人给出了解答:修改配置文件中的session.gc_maxlifetime。如果想了解更多session回收机制,继续阅读。(本文环境php5.2) 概述:每一次php请求,会有...

实例讲解PHP面向对象之多态

什么是多态性? 多态性是继数据库抽象和继承后,面向对象语言的第三个特征。多态即多种形态,具有表现多种形态的能力特征。在面向对象中表示根据对象的类型以不同方式处理。多态性允许每个对象以适合...

PHP+jquery实时显示网站在线人数的方法

本文实例讲述了PHP+jquery实时显示网站在线人数的方法。分享给大家供大家参考。具体分析如下: 在线人数最简单的就是直接利用js调用php,这样可以显示出有多少人访问了本站,如果要在...

php5.5新数组函数array_column使用

PHP5.5发布了,其中增加了一个新的数组函数array_column,感觉不错的!但是低版本PHP要使用,得自己实现:参考地址:https://wiki.php.net/rfc/arr...

PHP 登录完成后如何跳转上一访问页面

项目需求 访问网站页面时,有的页面需要授权才能访问,这时候就会要求用户登录,跳转到登录页面login.php,怎么实现登录后返回到刚才访问的页面。解决思路1: 在跳转...