6

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?

Community
  • 1
  • 1
chris
  • 6,653
  • 6
  • 41
  • 54
  • this is a post for the facebook problem http://stackoverflow.com/questions/7131909/facebook-callback-appends-to-return-url – chris Sep 07 '11 at 18:43

2 Answers2

3

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 :/

Brenden
  • 7,708
  • 11
  • 61
  • 75
2

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.

chris
  • 6,653
  • 6
  • 41
  • 54
  • 1
    You can set it with the PHP `header`, just include the hash: `header('Location: http://myurl.com/home#');` – kasimir Sep 04 '14 at 12:41