PHP 位置标头忽略哈希值

发布于 2024-12-03 13:45:29 字数 511 浏览 1 评论 0原文

可能的重复:
URL 片段和 302 重定向

我正在将 Facebook 登录集成到我的网站中。当 Facebook 使用代码查询参数重定向到我的网站时,末尾有一个哈希 http://myurl.com/code=xxx#_=_ 然后,当我从这个网址重定向到我网站上的另一个网址时:

header('Location: http://myurl.com/home');

它保留哈希标签并最终为 http://myurl.com/home#_=_

有没有一种方法可以在不使用重定向的情况下进行重定向哈希值,或者如果有人熟悉 Facebook,有办法让它停止添加哈希值吗?

Possible Duplicate:
URL Fragment and 302 redirects

I am integrating Facebook login into my site. When Facebook redirects to my site with the code query parameter, there is a hash at the end http://myurl.com/code=xxx#_=_
When I then redirect from this url to another url at my site:

header('Location: http://myurl.com/home');

It keeps the hash tag and ends up as http://myurl.com/home#_=_

Is there a way to redirect without the hash or if anyone is familiar with Facebook a way to get it to stop adding the hash in the first place?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掐死时间 2024-12-10 13:45:29

您可以在服务器端 PHP 重定向到包含其自己的哈希值的 URL。这就是我必须做的一个使用backbone.js 的ruby 应用程序。

PS - 我指定了 redirect_uri 并且 FB 仍然附加了愚蠢的 #_=_ 字符串:/

You can redirect on your server side PHP to a URL that includes its own hash. That's what I had to do a ruby app that uses backbone.js.

PS - I specified the redirect_uri and FB still appended the stupid #_=_ string :/

笑叹一世浮沉 2024-12-10 13:45:29

JavaScript 似乎是删除哈希值的唯一方法,因为哈希值永远不会以任何方式发送到服务器。所以我在空白页中添加了一个脚本:

window.location.hash = '';  window.location.href = "http://myurl.com"

这是目前的答案,但我会接受更好的答案。

It seems JavaScript is the only way to remove a hash since the hash is never sent to the server in any way. So I added a script to a blank page:

window.location.hash = '';  window.location.href = "http://myurl.com"

This is the answer for now, but I will accept better ones.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文