Search code examples
ajaxurlfacebook-comments

"facebook comment id" added to url - inconveniently


A user comments on the page, the comment is posted to their facebook wall. When another facebook user clicks the link to see the comment it links back to the page but with a massive string of numbers on the end.

http://canofclouds.com/thought/?fb_comment_id=fbc_10150505683457013_20914817_10150507783662013#55

The original url was: http://www.canofclouds.com/thought/#55

This is all fine so far though, until the user clicks a button to go to

http://www.canofclouds.com/thought/#56

Instead, it goes to:

http://canofclouds.com/thought/?fb_comment_id=fbc_10150505683457013_20914817_10150507783662013#f25e670a6c

Which is not good - because it doesn't exist. Ideally it would just go to http://www.canofclouds.com/thought/#56

Normally, when the user clicks the next button a flurry of javascript grabs the hash key (in this case #55) then adds 1 to it (to make #56 - yay) and executes an ajax call to grab the new content. This facebook stuff is making things a little complicated though.

Any ideas?

Edit: Even more ideally i could disable the 'fb comments id' altogether.


Solution

  • You shouldn't use hash keys to link to your page. You should use a canonical URL to do so.

    There are a few questions here on stack overflow about how to deal with this.

    The only way around it if you choose not to make canonical urls, is to do URL Rewriting at the network or web server level.