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加密解密函数Authcode()修复版代码

Authcode这个函数很多人都使用,这函数来自Discuz程序,用于加密解密字符串,可以设置钥匙(key)和过期时间,在很多时候都用得着。原版的函数代码可能会生成+、/、&这样的字符,...

phpinfo无法显示的原因及解决办法

phpinfo无法显示的原因及解决办法

今天调试lnmp环境,出现如下报错。无法查询到php信息。 环境:linux版本CentOS Linux release 7.3.1611 (Core),nginx使用tengine。...

PHP解压ZIP文件到指定文件夹的方法

本文实例讲述了PHP解压ZIP文件到指定文件夹的方法。分享给大家供大家参考,具体如下: /** * function: 解压zip 格式的文件 * author:friker...

教你识别简单的免查杀PHP后门

一个最常见的一句话后门可能写作这样 <?php @eval($_POST['cmd']);?> 或这样 <?php @asser...

用C/C++扩展你的PHP 为你的php增加功能

用C/C++扩展你的PHP 为你的php增加功能

英文版下载: PHP 5 Power Programming https://www.jb51.net/books/61020.html PHP取得成功的一个主要原因之一是她拥有大量的可...