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

相关文章

Laravel中使用FormRequest进行表单验证方法及问题汇总

在`Laravel`中,每一个请求都会被封装为一个`Request`对象,`Form Request`对象就是包含了额外验证逻辑(以及访问权限控制)的自定义`Request`类。 本文分...

PHP 数组基本操作小结(推荐)

数组的概念 数组(array)是 PHP 中一个非常重要的概念,我们可以把数组看做一系列类似的数据的集合,实际上数组是一个有序图。 PHP 还提供了超过 70 个内建函数来操作数组。 创...

基于PHP常用字符串的总结(待续)

1.分割与合并implode:echo implode(",", array('lastname', 'email', 'phone'));//数组转成字符串explode:print_...

php实现通过cookie换肤的方法

本文实例讲述了php实现通过cookie换肤的方法。分享给大家供大家参考。具体如下: saveStyleSheet.php页面如下: <?php function s...

PHP使用feof()函数读文件的方法

本文实例讲述了PHP使用feof()函数读文件的方法。分享给大家供大家参考。具体用法如下: feof应用于PHP 4, PHP 5 -用来测试文件指针是否到了文件结束的位置。 如果服务...