标题位置相对路径兼容性 [英] Header Location relative path compatibility
问题描述
这个相对位置 html标头是否与所有平台上的所有浏览器完全兼容?任何标准?
位置:some_script.php?la = 2& po = 2030
我的意思是,它会在当前目录下重定向到some_script.php吗?
header('Location:http:/ h2_lin>解决方案
/www.mywebsite.com/yourpage.php?id=32',TRUE,302);
但是要回答您的问题,是的,它会重定向到当前文件夹中的页面X首先不要斜杠或完整的网址。
这是我建议你为每个网站做的一个想法。在你的主文件(主要的php文件,你使用像config或其他)中,创建类似的东西:
','http://www.mywebsite.com/');所以当你创建一个重定向,一个链接或者其他的东西时,你可以这样做:
header('Location:'.URL.'yourpage.php?id = 32',TRUE,302);
编辑:2017年11月。正如下面的@jordanbtucker所指出的,HTTP规范已于2014年6月更新(这篇文章是从2012年开始的),以允许位置标题中的相对URI。
Is this relative location html header absolutely compatible with all browsers at all platforms? Any standards ?
Location: some_script.php?la=2&po=2030
I mean, will it always redirect to some_script.php at the current dir or not?
The standard would be this:
header('Location: http://www.mywebsite.com/yourpage.php?id=32', TRUE, 302);
But to answer your question, yes it will redirect to the page X in the current folder if you don't put a slash at first or a complete URL.
Here's an idea I would suggest you do for every website you do. In your primary file (the main php file you use like config or whatever), create something like that :
define('URL', 'http://www.mywebsite.com/');
So when you create a redirection, a link or whatever, you do this :
header('Location: '.URL.'yourpage.php?id=32', TRUE, 302);
EDIT: November 2017. As pointed by @jordanbtucker below, the HTTP spec has been updated in June 2014 (this post is from 2012) to allow relative URIs in the Location header.
这篇关于标题位置相对路径兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!