Skip to content

Instantly share code, notes, and snippets.

@yasuhiro-matsuda
Created August 29, 2017 07:57
Show Gist options
  • Save yasuhiro-matsuda/fc87420f473796158672e829433c8851 to your computer and use it in GitHub Desktop.
Save yasuhiro-matsuda/fc87420f473796158672e829433c8851 to your computer and use it in GitHub Desktop.
SNSクローラーかBasic認証OKで通過させる apache 2.4
# SNSクローラーをenvに設定
SetEnvIf User-Agent ^facebookexternalhit.*$ fb_crawler
SetEnvIf User-Agent ^facebookplatform.*$ fb_crawler
SetEnvIf User-Agent ^Twitterbot.*$ tw_crawler
# どれか一致で通過
<RequireAny>
# クローラー
Require env fb_crawler
Require env tw_crawler
# Basic認証
AuthUserFile /var/www/html/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user
</RequireAny>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment