问题描述
这个相对位置 html 标头是否与所有平台的所有浏览器绝对兼容?有什么标准吗?
Is this relative location html header absolutely compatible with all browsers at all platforms? Any standards ?
Location: some_script.php?la=2&po=2030
我的意思是,它是否总是重定向到当前目录的 some_script.php?
I mean, will it always redirect to some_script.php at the current dir or not?
推荐答案
标准是这样的:
header('Location: http://www.mywebsite.com/yourpage.php?id=32', TRUE, 302);
但要回答您的问题,是的,如果您不首先输入斜杠或完整的 URL,它将重定向到当前文件夹中的页面 X.
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.
我建议您为您所做的每个网站都这样做.在您的主文件(您使用的主 php 文件,如 config 或其他文件)中,创建类似的内容:
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);
2017 年 11 月.正如下面 @jordanbtucker 所指出的,HTTP 规范已在 2014 年 6 月更新(这篇文章来自 2012 年),以允许在 Location 标头中使用相对 URI.
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.
这篇关于标头位置相对路径兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)