Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

He suggests using real URLs - instead of "/#!5753509/hello-world-this-is-the-new-lifehacker" we would have "/5753509/hello-world-this-is-the-new-lifehacker". Sounds great, but what happens when you click to a new article, which is loaded with AJAX?

Well you've already confirmed that the client is running Javascript so:

1. Use JavaScript to rewrite the existing clean URLs into JS function calls (or however you want to handle that)

2. Use window.history.pushState to push the clean (canonical) URL for the page you're viewing to the browser.

I'm not sure why this isn't obvious...



history.pushState() and history.replaceState() are introduced in the html 5 spec, so not all browsers support it yet.


Test for the API and fall back to the hashbangs if it isn't available. Check out this example in an old browser and a modern one:

http://www.asual.com/jquery/address/samples/express/portfoli...


My point was the degradation to hashbang (which is what most users are going to see) is absolutely horrid, to the point that I would actively avoid it.


You're concerned about /content/123/#!/content/456/, right?

Well, if the client isn't modern, 301 them to #!/content/456/ and proceed as you would.

Either way though, all this is terrible for a blog, or even Twitter.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: