Reputation: 12047
I am developing a new website for our company, so I have put the site on to the internet, but restricted access through .htaccess to certain IP addresses.
However, part of the new site is a 'Share on Facebook' button, so I need to test that, but Facebook is unable to connect to my site, and this is not grabbing the OpenGraph titles, descriptions, images, etc.
I've added allow from facebook.com
to .htaccess, but this doesn't work, and the Facebook linter reports a 403 when trying to connect. Temporaraly removing the access restrictions to the site allows the Facebook linter to connect.
Here is my full .htaccess file (minus real IP addresses) -
ErrorDocument 404 /index.php?error=404
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Only allow access to the site from the IP's listed below
#order deny,allow
allow from 1.2.3.1 # sh_adsl
allow from 1.2.3.2 #sh_lease_lines
allow from 1.3.1.1 # sh
allow from 1.2.2.1 # sm
allow from 1.2.3.1 # wi
allow from 1.2.4.1 # fr
allow from 4.3.2.1 # dgard - home local range
allow from facebook.com # to allow the Facebook sharing
#allow from all
deny from all
# Block access to wp-config.php
<Files wp-config.php>
order allow,deny
deny from all
</Files>
# Deny directory browsing
Options All -Indexes
# Prevent access to any file that begins with '.hta' (i.e. protect this file!)
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
Upvotes: 3
Views: 5259
Reputation: 53929
List of FB crawlers IPs: https://developers.facebook.com/docs/ApplicationSecurity/#facebook_scraper
Add them to your .htaccess
and you should be good to go.
Upvotes: 3