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 清空varnish 缓存的详解(包括指定站点下的)

没法清空文件夹内容 只能清空指定链接缓存复制代码 代码如下:<?phpfunction clearVarnish($ip,$url,$host=null){  ...

PHP实现的微信公众号扫码模拟登录功能示例

本文实例讲述了PHP实现的微信公众号扫码模拟登录功能。分享给大家供大家参考,具体如下: PHP微信公众号扫码模拟登录功能 功能只是将:https://github.com/huanz/w...

php数组排序usort、uksort与sort函数用法

本文实例讲述了php数组排序usort、uksort与sort函数用法。分享给大家供大家参考。具体用法分析如下: 对数组排序:usort() 函数使用用户自定义的函数对数组排序,实例代码...

解析PHP自带的进位制之间的转换函数

bindec() -- 二进制转换为十进制 decbin() -- 十进制转换为二进制 dechex() -- 十进制转换为十六进制 decoct() -- 十进制转换为八进制 hexd...