php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com5年前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数据库配置文件一般做法分享

config.php文件: 复制代码 代码如下: <?php $db_name="test"; $db_username="root"; global $db_password;...

php之CodeIgniter学习笔记

在使用数据库之前,我们最好将数据库进行自动连接:config/autoload.php自动加载 $autoload['libraries'] = array('database');一些...

php自定义二维数组排序函数array_orderby用法示例

本文实例讲述了php自定义二维数组排序函数array_orderby用法。分享给大家供大家参考,具体如下: <?php /** I came up with an ea...

Drupal 添加模块出现莫名其妙的错误的解决方法(往往出现在模块较多时)

状况如下: 1、点击保按钮后,不能正常转到页面,出现空白页面; 2、刷新页面,发出导航中许多项已经没有了,还存在的项点击也不能进入正常的页面。 测试了多次没有发现任何问题,多次重装、测试...

php实现获取近几日、月时间示例

本文实例讲述了php实现获取近几日、月时间。分享给大家供大家参考,具体如下: <?php date_default_timezone_set('Asia/Shangha...