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开发中常见的安全问题详解和解决方法(如Sql注入、CSRF、Xss、CC等)

浅谈Php安全和防Sql注入,防止Xss攻击,防盗链,防CSRF 前言: 首先,笔者不是web安全的专家,所以这不是web安全方面专家级文章,而是学习笔记、细心总结文章,里面有些是我们p...

PHP实现对二维数组某个键排序的方法

本文实例讲述了PHP实现对二维数组某个键排序的方法。分享给大家供大家参考,具体如下: /** * 对查询结果集进行排序 * @access public * @param ar...

dede3.1分页文字采集过滤规则详说(图文教程)

dede3.1分页文字采集过滤规则详说(图文教程)

本文旨在以一个有代表性的文字分页的取样规则和过滤规则为蓝本,通过简单的变通和改动,解决一般性文字分页的采集问题一、范例部分范例分页区域代码:范例分页区域代码:=700) window.o...

PHP排序之二维数组的按照字母排序实现代码

复制代码 代码如下: <?php /** * Sort an two-dimension array by some level two items use array_multi...

PHP实现将textarea的值根据回车换行拆分至数组

本文实例讲述了PHP实现将textarea的值根据回车换行拆分至数组的方法。分享给大家供大家参考。具体分析如下: textarea回车换行为 \r\n $keyword_list =...