php download.php实现代码 跳转到下载文件(response.redirect)
程序员文章站
2022-06-09 08:26:11
跳转核心代码实现。复制代码 代码如下:if (isset($link)) &...
跳转核心代码实现。
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
复制代码 代码如下:
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
上一篇: 夏季喝什么茶好,这里有过清凉夏季的秘密哦
下一篇: 吃什么补维生素e做好,几种食物告诉你