Facebook 分享显示 _escaped_fragment_ URL 而不是哈希版本
我创建了一个单页应用程序。所有深层链接均采用 mysite.com/#!/entry_title 的形式。这允许 Google(和 Facebook)检查该页面内容的备用 URL。
我已经设置了服务器端检查以确定 Google 或 Facebook 是否正在查找此页面的 HTML 快照。如果是这样,它会发送一个包含必要的 Facebook og 元标记的不同标头。
问题就在这里。如果我将 URL 之一 (mysite.com/#!/entry_title) 粘贴到状态框中,则显示的 URL 是 HTML 快照 URL (mysite.com/?_escaped_fragment_/entry_title)。
HTML 快照页面上的 og:url 元标记设置为 mysite.com/#!/entry_title。
如何使共享器显示 URL 的 mysite.com/#!/entry_title 版本而不是 HTML 快照版本?
提前致谢!
- 布雷特
I've created a single-page app. All deep links are in the form of mysite.com/#!/entry_title. This allows Google (and Facebook) to check an alternate URL for the content of that page.
I've setup a server-side check to determine if Google or Facebook is looking for the HTML snapshot of this page. If so, it sends a different header containing the necessary Facebook og meta tags.
Here's the problem. If I paste one of my URLs (mysite.com/#!/entry_title) into my status box the URL that gets displayed is the HTML snapshot URL (mysite.com/?_escaped_fragment_/entry_title).
The og:url meta tag on the HTML snapshot page is set to mysite.com/#!/entry_title.
How can I make the Sharer display the mysite.com/#!/entry_title version of the URL instead of the HTML snapshot version?
Thanks in advance!
- Brett
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经弄清楚了这一点,并认为我会为其他人发布答案。
诀窍是为 Google/Facebook 设置重定向以转到更漂亮的 URL。因此,任何形式的 URL
都会被重定向到更漂亮的内容,例如
当有人分享我的动态 URL 之一时,Facebook 会请求该页面的 _escaped_fragment_ 版本,并被重定向到我的更漂亮的 URL (mysite.com/view/entry_title),即Facebook 帖子中显示的内容。
为了确保人们始终共享我的动态 URL,我在 mysite.com/view/entry_title 页面上设置了 javascript 重定向,以重定向回 mysite.com/#!/entry_title 页面。
虽然这不会显示 Facebook 共享中的动态 URL,但它会显示比 _escaped_fragment_ 版本更漂亮的 URL,并迫使人们回到我希望人们共享的动态 URL。
I've figured this out and thought I'd post the answer for others.
The trick is to setup a redirect for Google/Facebook to go to a prettier URL. So any URL in the form of
gets redirected to something prettier like
When someone shares one of my dynamic URLs, Facebook requests the _escaped_fragment_ version of the page, and gets redirected to my prettier URL (mysite.com/view/entry_title), which is what gets shown in the Facebook post.
To make sure people always share my dynamic URL I've setup a javascript redirect on the mysite.com/view/entry_title pages to redirect back to the mysite.com/#!/entry_title pages.
While this doesn't show the dynamic URL in the Facebook Share, it shows a prettier URL than the _escaped_fragment_ version and forces people back to the dynamic URL that I want people to share.