web-dev-qa-db-ja.com

Facebookクローラーを次のHtaccessリダイレクトから除外しますか?

私は最近自分のウェブサイトをhttpsにしましたが、以前のURL(http)には多くのFacebookのいいねがあったので、新しいhttps URLに移行したいと思います。 URLへの唯一の変更はhttpsであり、ドメインの変更はありません。

Facebookからアドバイスされた移行手順に従いましたが、次のエラーに遭遇しました(developers.facebook.comのOpen Graph Object Debuggerによる)。

Critical Errors That Must Be Fixed.
Could Not Follow Redirect Path.
Using data from https://www.myurl.com because there was an error following the redirect path.

Errors That Must Be Fixed.
Circular Redirect Path.
Circular redirect path detected (see 'Redirect Path' section for details).
Could Not Follow Redirect.
URL requested a HTTP redirect, but it could not be followed.

To find the object, these are the redirects we had to follow.
original http://www.myurl.com
302 https://www.myurl.com
og:url http://www.myurl.com

これを修正する方法がわかりません。明らかに、httpからhttpsへの変更のため、.htaccessでhttpからhttpsへの301リダイレクトがあり、これが問題の原因であると思います。アイデアはありますか?

更新...

私がする必要があるのは、Facebookのクローラーを除外することです(どうすればそれを特定できますか?) http://www.myurl.com から https:// www。 myurl.com リダイレクト。現時点では、.htaccessファイルは次のようになっています...

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/contact-us\.php
RewriteRule ^ https://%{HTTP_Host}%{REQUEST_URI}

RewriteCond %{HTTPS} on
RewriteRule ^contact-us\.php http://%{HTTP_Host}/contact-us.php [NC,L,R=301]

1つのphpページを除き、httpからhttpsにリダイレクトされています。しかし、Facebookのクローラーが自動的にhttpsにアクセスしないようにするにはどうすればよいですか?

1
Lindy

Facebookのクローラーがサイトをクロールするとき、301リダイレクトを無効にする必要があります。 ジョンリン 言う StackOverflowで

この質問 は、facebookの外部ヒットが表示されるユーザーエージェントに対応します。確認する条件を追加するだけです。

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule (.*) https://%{HTTP_Host}%{REQUEST_URI}
1
Nona Man