php download.php实现代码 跳转到下载文件(response.redirect)
2015-01-24信息快讯网
一直对php不太熟悉,今天需要类型asp的 response.redirect语句,但一直没有很好的解决方法。下面是问了朋友才知道的。
跳转核心代码实现。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: http://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处理json时中文问题的解决方法
深入理解PHP原理之Session Gc的一个小概率Notice
The specified CGI application misbehaved by not returning a complete set of HTTP headers
PHP stream_context_create()作用和用法分析
php中突破基于HTTP_REFERER的防盗链措施(stream_context_create)
PHP 5.3 下载时 VC9、VC6、Thread Safe、Non Thread Safe的区别分析
php模拟asp中的XmlHttpRequest实现http请求的代码
php expects parameter 1 to be resource, array given 错误
WordPress判断用户是否登录的代码
PHP中uploaded_files函数使用方法详解
延长phpmyadmin登录时间的方法
PHP中simplexml_load_string函数使用说明
PHP类(Class)入门教程第1/2页
php 文件夹删除、php清除缓存程序
PHP has encountered an Access Violation at 7C94BD02解决方法
PHP 实现多服务器共享 SESSION 数据
彻底杜绝PHP的session cookie错误
PHP file_get_contents 函数超时的几种解决方法
PHP PDO函数库(PDO Functions)第1/2页
php str_pad 函数用法简介
phpmyadmin MySQL 加密配置方法
php addslashes 函数详细分析说明
phpmyadmin 访问被拒绝的真实原因
php ignore_user_abort与register_shutdown_function 使用方法
php adodb连接mssql解决乱码问题
php session 错误
php 无限级 SelectTree 类
对squid中refresh_pattern的一些理解和建议
php SQL之where语句生成器