Skip to content

Instantly share code, notes, and snippets.

@kentwidman
Last active December 25, 2015 07:29
Show Gist options
  • Save kentwidman/6940117 to your computer and use it in GitHub Desktop.
Save kentwidman/6940117 to your computer and use it in GitHub Desktop.
Password protected .htaccess allowing Facebook Crawler access
SetEnvIfNoCase User-Agent .*google.* search_robot
Order Deny,Allow
Deny from All
Allow from env=search_robot
#password
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
Order deny,allow
Deny from all
# Generate ip/port list by run the folling command.
# whois -h whois.radb.net -- '-i origin AS32934' | grep ^route
# http://www.askapache.com/htaccess/301-redirect-with-mod_rewrite-or-redirectmatch.html
Allow from 31.13.24.0
Allow from 31.13.64.0
Allow from 66.220.144.0
Allow from 69.63.176.0
Allow from 69.171.224.0
Allow from 74.119.76.0
Allow from 103.4.96.0
Allow from 173.252.64.0
Allow from 204.15.20.0
Allow from 204.15.20.0/22
Allow from 69.63.176.0/20
Allow from 66.220.144.0/20
Allow from 66.220.144.0/21
Allow from 69.63.184.0/21
Allow from 69.63.176.0/21
Allow from 74.119.76.0/22
Allow from 69.171.255.0/24
Allow from 173.252.64.0/18
Allow from 69.171.224.0/19
Allow from 69.171.224.0/20
Allow from 103.4.96.0/22
Allow from 69.63.176.0/24
Allow from 173.252.64.0/19
Allow from 173.252.70.0/24
Allow from 31.13.64.0/18
Allow from 31.13.24.0/21
Allow from 66.220.152.0/21
Allow from 66.220.159.0/24
Allow from 69.171.239.0/24
Allow from 69.171.240.0/20
Allow from 31.13.64.0/19
Allow from 31.13.64.0/24
Allow from 31.13.65.0/24
Allow from 31.13.67.0/24
Allow from 31.13.68.0/24
Allow from 31.13.69.0/24
Allow from 31.13.70.0/24
Allow from 31.13.71.0/24
Allow from 31.13.72.0/24
Allow from 31.13.73.0/24
Allow from 31.13.74.0/24
Allow from 31.13.75.0/24
Allow from 31.13.76.0/24
Allow from 31.13.77.0/24
Allow from 31.13.96.0/19
Allow from 31.13.66.0/24
Allow from 173.252.96.0/19
Allow from 69.63.178.0/24
Allow from 31.13.78.0/24
Allow from 31.13.79.0/24
Allow from 31.13.80.0/24
Allow from 31.13.82.0/24
Allow from 31.13.83.0/24
Allow from 31.13.84.0/24
Allow from 31.13.85.0/24
Allow from 31.13.86.0/24
Allow from 31.13.87.0/24
Allow from 31.13.88.0/24
Allow from 31.13.89.0/24
Allow from 31.13.90.0/24
Allow from 31.13.91.0/24
Allow from 31.13.92.0/24
Allow from 31.13.93.0/24
Allow from 31.13.94.0/24
Allow from 31.13.95.0/24
Allow from 69.171.253.0/24
Allow from 69.63.186.0/24
Allow from 31.13.81.0/24
Allow from 204.15.20.0/22
Allow from 69.63.176.0/20
Allow from 69.63.176.0/21
Allow from 69.63.184.0/21
Allow from 66.220.144.0/20
Allow from 69.63.176.0/20
Allow from 2620:0:1c00::/40
Allow from 2a03:2880::/32
Allow from 2401:DB00::/32
Allow from 2a03:2880:fffe::/48
Allow from 2a03:2880:ffff::/48
Allow from 2620:0:1cff::/48
Allow from 2a03:2880:f000::/48
Allow from 2a03:2880:f001::/48
Allow from 2a03:2880:f002::/48
Allow from 2a03:2880:f003::/48
Allow from 2a03:2880:f004::/48
Allow from 2a03:2880:f005::/48
Allow from 2a03:2880:f006::/48
Allow from 2a03:2880:f007::/48
Allow from 2a03:2880:f008::/48
Allow from 2a03:2880:f009::/48
Allow from 2a03:2880:f00a::/48
Allow from 2a03:2880:f00b::/48
Allow from 2a03:2880:f00c::/48
Allow from 2a03:2880:f00d::/48
Allow from 2a03:2880:f00e::/48
Allow from 2a03:2880:f00f::/48
Allow from 2a03:2880:f010::/48
Allow from 2a03:2880:f011::/48
Allow from 2a03:2880:f012::/48
Allow from 2a03:2880:f013::/48
Allow from 2a03:2880:f014::/48
Allow from 2a03:2880:f015::/48
Allow from 2a03:2880:f016::/48
Allow from 2a03:2880:f017::/48
Allow from 2a03:2880:f018::/48
Allow from 2a03:2880:f019::/48
Allow from 2a03:2880:f01a::/48
Allow from 2a03:2880:f01b::/48
Allow from 2a03:2880:f01c::/48
Allow from 2a03:2880:f01d::/48
Allow from 2a03:2880:f01e::/48
Allow from 2a03:2880:f01f::/48
#google plus this is a security hole since it UA can be faked, but will most people will not figure it out.
Allow from env=search_robot
Satisfy any
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment