LoginSignup
0
0

More than 3 years have passed since last update.

開発中のサイトでFetch As Googleを利用する

Posted at

私のやり方が正しいのか自信はありませんが、
試してみたら出来たので備忘録として書きます。

実装

こんな風にGoogleBotだけBASIC認証を解除したら、サイトをクロールしてくれます。

.htaccess
AuthUserFile /path/to/project/.htpasswd
AuthType Basic
AuthName "Web access"
Require valid-user

Satisfy any
BrowserMatchNoCase Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) isGoogleBot=1
BrowserMatchNoCase Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36 isGoogleBot=1

allow from env=isGoogleBot

やりたいこと

  • GoogleBotから自分のサイトがどのように見えるのかを確認したい

やり方

  • Google Search ConsoleのFetch As Googleを用いる
  • 開発中のサイトURLをGoogle Search Consoleに登録し、一度GoogleBotにクロールしてもらう

問題

  • 開発中のサイトはBASIC認証を設けているため、GoogleBotからはアクセスできない

考えた対処策

  • GoogleBotのUser-AgentだけBASIC認証を解除したらクロールできるのでは? できた。

備考

GoogleのUAは以下のサイトから確認できます
https://support.google.com/webmasters/answer/1061943?hl=ja

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0