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开发框架总结收藏

开发框架WACT http://wact.sourceforge.net/老牌的PHP编程框架,实现了很多企业级的开发模式Horde http://www.horde.org/horde...

php字符串操作针对负值的判断分析

本文实例分析了php字符串操作针对负值的判断方法。分享给大家供大家参考,具体如下: $a = '-1'; $b = (int)$a; $c = is_numeric($a); if...

PHP实现获取域名的方法小结

本文实例总结了PHP实现获取域名的方法。分享给大家供大家参考。具体实现方法如下: 方法一(用 系统变量)    复制代码 代码如下://缺点不使用传递过来的地址和不支持系统变量的主机  ...

PHP获取文件行数的方法

本文实例讲述了PHP获取文件行数的方法。分享给大家供大家参考。具体分析如下: 提供两种实现方法,虽然第二种简单易懂,但是第一种效率最好 第一种: <?php $fil...

PHP实现桶排序算法

简单意义上的桶排序: 桶排序的原理是先安排N+1个桶作为容器,若数据范围为N的话。 然后将测试数据(所需排序的数据)进行循环,放入对应的桶内。数据一定是在范围N内的。 最后,循环桶里的元...