3

我正在为我们公司开发一个新网站,因此我已将该网站放到互联网上,但通过 .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>
4

1 回答 1

3

FB爬虫IP列表:https ://developers.facebook.com/docs/ApplicationSecurity/#facebook_scraper

将它们添加到你的.htaccess,你应该很高兴。

于 2013-01-31T14:49:44.037 回答