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

相关文章

THINKPHP支持YAML配置文件的设置方法

为什么要用 yaml 因为 Yaml 简单,而且对人类友好; Yaml: http://www.yaml.org/ 在哪里会用到? 最基本的,在 ThinkPHP 的配置文件里面就可以选...

关于PHP中协程和阻塞的一些理解与思考

前言 本文主要给大家介绍了关于PHP中协程和阻塞的理解与思考,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍: 进程、线程、协程 关于进程、线程、协程,有非常详细和丰富的...

php中常用的预定义变量小结

复制代码 代码如下: <?php echo "当前操作系统信息".PHP_OS."<br/>"; echo '本文件路径和文件名为:'.__FILE__.'<br...

discuz authcode 经典php加密解密函数解析

原理如下,假如: 加密 明文:1010 1001 密匙:1110 0011 密文:0100 1010 得出密文0100 1010,解密之需和密匙异或下就可以了 解密 密文:0100 10...

php中http与https跨域共享session的解决方法

遇到了HTTP、HTTPS协议下session共享解决cookie失效的问题,这里提供一个临时解决办法。 实现原理:把session id设置到本地的cookie。 如下: 复制代码 代...