允许Facebook访问我的网站,以便它可以读取Open Graph元标记

时间:2013-01-31 14:39:33

标签: facebook apache .htaccess opengraph

我正在为我们公司开发一个新网站,所以我把网站放到互联网上,但限制通过.htaccess访问某些IP地址。

然而,新网站的一部分是“在Facebook上分享”按钮,所以我需要测试一下,但Facebook无法连接到我的网站,这不是抓住OpenGraph标题,描述,图像等

我已将allow from facebook.com添加到.htaccess,但这不起作用,Facebook linter在尝试连接时报告403。暂时删除对网站的访问限制允许Facebook linter连接。

这是我的完整.htaccess文件(减去真实的IP地址) -

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>

1 个答案:

答案 0 :(得分:3)

FB抓取工具IP列表:https://developers.facebook.com/docs/ApplicationSecurity/#facebook_scraper

将它们添加到.htaccess,你应该好好去。