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面向对象程序设计OOP继承用法入门示例

本文实例讲述了PHP面向对象程序设计OOP继承用法。分享给大家供大家参考,具体如下: <?php class Person { var $name;//protec...

PHP实现过滤掉非汉字字符只保留中文字符

<?php $str = "a 1b 2b<中文>。xxyy字符"; //转换 GB2312 -> UTF-8 $str = mb_convert_encod...

php简单压缩css样式示例

本文实例讲述了php简单压缩css样式的方法。分享给大家供大家参考,具体如下: $css = ''; //找css目录 $root = $_SERVER['DOCUMENT_ROOT...

教你识别简单的免查杀PHP后门

一个最常见的一句话后门可能写作这样 <?php @eval($_POST['cmd']);?> 或这样 <?php @asser...

PHP Post获取不到非表单数据的问题解决办法

问题描述 在使用vue-axios向后端post数据时,PHP端获取不到post的数据。 问题解决 修改php.ini配置 找到php.ini配置文件,查找enable_post_...