Facebook OG gets redirected to the index page by BackboneJS website

二次信任 提交于 2020-01-13 19:32:27

问题


I have a website that is created using BackboneJS and I am trying to implement Facebook OG so that when user pastes my site's URL from the Facebook status, it will display the title, images and etc.

My problem is that the FB scraper is getting redirected always to the index page due that Apache redirects all traffic to the index page so BB router can work properly. It only sees the og title, og image and etc that was for the index page and not on my other page.

Facebook scraper/crawler does not seem to be going through the BB router. It just renders the static index.html page.

Has anyone got a workaround/solution for this one?


回答1:


You can use Facebook Lint tool to debug OG objects, here it is on one of your domain links:

http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fembedible.com%2Fvideo%2FamQ1Njg4QGdtYWlsLmNvbTI5OA%3D%3D

Notice that you have a problem with the og:url that shows http://embedible.com/ although your OG object url is actually http://embedible.com/video/amQ1Njg4QGdtYWlsLmNvbTI5OA==

you can see it on the Redirect Path section of the lint debugger, the actual url that was scrapped is http://embedible.com/

On my website we render the same html template with different data based on the url. So I have 2 template engines one for real views on the client and one on the server that fill the meta tags

Bottom line: you must replace the meta tags on your Server.




回答2:


I would suggest configuring the Facebook Open Graph tags in you're websites HTML itself (not Backbone). FB has special tags that it uses to generate the little previews. Here are the docs.

The Facebook scraper/crawler is not going through the backbone routes probably because it doesn't run javascript.

Since it doesn't run JS, you could set up a script to read the request uri when pages hit index.html, then redirect to a page with the appropriate OG tags.




回答3:


CamelBlues, I don't think this is the solution I am looking for. Firstly, I am already using OG tags on my site. Secondly, I don't think crawler needs to know how to read JS but the page that JS renders depending on the URI... this is how the Backbone.js router works. And,

"Since it doesn't run JS, you could set up a script to read the request uri when pages hit index.html, then redirect to a page with the appropriate OG tags."

this is what the BB router is doing already and my pages have the appropriate OG tags. :(



来源:https://stackoverflow.com/questions/15138288/facebook-og-gets-redirected-to-the-index-page-by-backbonejs-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!