How to fix Facebook Circular Redirect?

2020-05-24 19:34发布

I have a page that redirects to another page I'm trying to test my url on: https://developers.facebook.com/tools/debug

I get this error:

Errors That Must Be Fixed:
Circular Redirect:‎ Circular redirect path detected (see Redirect Path section for details).

Warnings That Should Be Fixed:
‎The og:url property should be explicitly provided, even if a value can be inferred from other
tags.‎
  1. How can I fix this problem?
  2. How to detect Facebook and, if it is Facebook, don't redirect?

8条回答
我只想做你的唯一
2楼-- · 2020-05-24 19:59

I just resolved this by adding a "/" to the end of the Facebook url meta tag. So, changed

<meta property="og:url" content="http://domain.com/path"/>

to

<meta property="og:url" content="http://domain.com/path/"/>

and that did the trick!

查看更多
▲ chillily
3楼-- · 2020-05-24 20:02

I had same error: In my case the problem was www. in canonical url against fetched. Matched and problem disappeared.

查看更多
贪生不怕死
4楼-- · 2020-05-24 20:10

Maybe adding the title after the page load helps

<script type="text/javascript">
// <![CDATA[
    var meta = document.createElement('meta');
    meta.setAttribute("property", "og:url");
    meta.setAttribute("content", location.href);
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(meta);    
// ]]>
</script>

http://digdog.tumblr.com/post/1134982957/integrate-tumblr-template-with-facebook-open-graph

查看更多
甜甜的少女心
5楼-- · 2020-05-24 20:18

It should be clear from the details given below in the redirect path section of the debugger output: In most cases this happens because you've specified an og:url tag pointing to (for example) 'mysite.com/articles' and this redirects to 'mysite.com/articles/' - the crawler then goes to 'mysite.com/articles' and gets the og:url tag pointing it back to 'mysite.com/articles'

查看更多
我命由我不由天
6楼-- · 2020-05-24 20:18

Check the Canonical URL in https://developers.facebook.com/tools/debug as to where it's getting redirected. If there is a 302 redirect, then either you have to remove that redirect or give the redirected path as og:URL meta tag value.

If http is getting redirect to https. Then give https://your-sitename.com as the new value of og:URL.

Please note this will reset your all old comments.

查看更多
女痞
7楼-- · 2020-05-24 20:21

I've found a workaround and although it's on a LAMP stack something similar must be possible with .NET.

Checking the Apache server log while using the Facebook Linter I got:

69.63.189.246 - - [09/Jan/2012:03:54:45 +0000] "GET /test1.php HTTP/1.1" 200 8879 "-" > "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"

I now check if the User-Agent contains: facebookexternalhit if so I display the original page, if not I redirect to the new url.

You can use the following RewriteCond in Apache to make sure that your rewrite rule will only run if the User-Agent IS NOT (pay attention to the exclamation mark) facebookexternalhit.

RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit

This solution is risky, if Facebook decides to change their User-Agent header you will be royally ... but for now it seems to do the trick.

查看更多
登录 后发表回答