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中通过语义URL防止网站被攻击的方法分享

什么是语义URL 攻击? 好奇心是很多攻击者的主要动机,语义URL 攻击就是一个很好的例子。此类攻击主要包括对URL 进行编辑以期发现一些有趣的事情。 例如,如果用户chris 点击了你...

php把大写命名转换成下划线分割命名

有时候需要把一个字符串中的大写转换成 _+小写的方式,在变量命名的时候会碰到这种问题,直接上代码: $name = 'AppPromoZhongQiu2014ActiveStatus...

PHP函数preg_match_all正则表达式的基本使用详细解析

了解正则表达式之前,须要掌握一些常用的正则表达式的基础知识,这些如果能记得最好记得,记不住须要用的时候能查到就行,就多个特殊字符,所以说正则表达式玩的就是特殊,具体大家可以查看更加细致的...

批量获取memcache值并按key的顺序返回的实现代码

通过memcached的getMulti函数来批量获取如下15个ID的值。 31639,33878,177410,9735,589,12076,25953,22447,15368,153...

取得单条网站评论以数组形式进行输出

原库函数中,没有获取单条评论显示的方法,增加如下 public static function single($id){ global $db; return $db->qu...