Facebook共享显示_escaped_fragment_ URL而不是哈希版本 [英] Facebook Share showing _escaped_fragment_ URL instead of hash version

查看:69
本文介绍了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快照版本?

提前谢谢!

  • 布雷特

解决方案

我已经弄清楚了,并认为我会为其他人发布答案.

诀窍是为Google/Facebook设置重定向以转到更漂亮的URL.因此,任何

形式的URL

mysite.com/?_escaped_fragment_/entry_title 

被重定向到更漂亮的东西

mysite.com/view/entry_title

当某人共享我的动态URL之一时,Facebook请求该页面的_escaped_fragment_版本,并重定向到我更漂亮的URL(mysite.com/view/entry_title),这是在Facebook帖子中显示的. >

为确保人们总是共享我的动态URL,我在mysite.com/view/entry_title页面上设置了javascript重定向,以重定向回mysite.com/#!/entry_title页面.

尽管它在Facebook Share中未显示动态URL,但它显示的URL比_escaped_fragment_版本更漂亮,并迫使人们回到我希望人们共享的动态URL.

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

解决方案

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

mysite.com/?_escaped_fragment_/entry_title 

gets redirected to something prettier like

mysite.com/view/entry_title

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.

这篇关于Facebook共享显示_escaped_fragment_ URL而不是哈希版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆