Allow Facebook to test your Open Graph meta tags ( og debugger ) with htpasswd password

If you are developing new site, you have probably locked it through htpasswd. When you are done with og meta data, you might want to check it with https://developers.facebook.com/tools/debug/sharing/ – but facebook won’t be able to access your content, because you can’t give it your password.

You need to update your htaccess, from

AuthUserFile /.htpasswd
AuthName Disbait
AuthType Basic
Require valid-user
satisfy any
deny from all
allow from 127.0.0.1

to

SetEnvIfNoCase User-Agent "^facebookexternalhit" facebook
SetEnvIfNoCase User-Agent "Facebot" facebook
SetEnvIfNoCase User-Agent "Twitterbot" twitter

AuthUserFile /.htpasswd
AuthName "Restricted Access"
AuthType Basic
Require valid-user
satisfy any
deny from all
allow from 127.0.0.1
allow from env=facebook
allow from env=twitter

Credit coderwall.com/p/8y7t1q/whitelist-facebook-twitter-to-test-your-open-graph-and-twitter-card-implementations

Write a Comment

Comment