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中strnatcmp()函数“自然排序算法”进行字符串比较用法分析(对比strcmp函数)

本文实例讲述了PHP中strnatcmp()函数“自然排序算法”进行字符串比较用法。分享给大家供大家参考,具体如下: PHP中strnatcmp()函数使用"自然"算法来比较两个字符串(...

浅析php fwrite写入txt文件的时候用 \r\n不能换行的问题

今天遇到了一个问题就是用fwrite写入txt文件的时候用 rn不能换行试了很久都没找到办法!突然之间想到一个东东以前看书见过后来还是用这个东东给解决了!现在写出来预防将来忘记也希望能帮...

PHP获取当前页面完整URL的实现代码

javascript实现:复制代码 代码如下:top.location.href   顶级窗口的地址 this.location.href  当前窗口的地址...

Ubuntu server 11.04安装memcache及php使用memcache来存储session的方法

本文实例讲述了Ubuntu server 11.04安装memcache及php使用memcache来存储session的方法。分享给大家供大家参考,具体如下: 1、首先安装memcac...

PHP中auto_prepend_file与auto_append_file用法实例分析

本文实例讲述了PHP中auto_prepend_file与auto_append_file的用法,是PHP程序设计中比较实用的技巧。分享给大家供大家参考。具体方法如下: 如果需要将文件r...