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-fpm超时时间设置request_terminate_timeout资源问题分析

php-fpm超时时间设置request_terminate_timeout资源问题分析

php日志中有一条超时的日志,但是我request_terminate_timeout中设置的是0,理论上应该没有超时时间才对。 PHP Fatal error: Maximum exe...

php cookie中点号(句号)自动转为下划线问题

php cookie中不能使用点号(句号),实际上不是很严格,应该说可以使用点号的cookie名,但会被转换,你命名一个cookie: $_COOKIE[‘my.name'] = 1;...

php Ubb代码编辑器函数代码

复制代码 代码如下: <?php /* php Ubb代码编辑器 */ function get_ubb($ubb){ $ubb=preg_replace("/([B])(.*)(...

php计算指定目录下文件占用空间的方法

本文实例讲述了php计算指定目录下文件占用空间的方法。分享给大家供大家参考。具体分析如下: php中可以通过 RecursiveDirectoryIterator 扩展 Director...

简单的PHP多图上传小程序代码

先上源代码,你可以copy到自己的电脑上去运行~ 复制代码 代码如下: <html> <meta http-equiv="Content-Type" content="...