Header Location relative path compatibility(Header Location 相对路径兼容性)
问题描述
此相对位置 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 文件,如配置或其他文件)中,创建类似的内容:
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.
这篇关于Header Location 相对路径兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Header Location 相对路径兼容性
基础教程推荐
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
