Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
13 views
in Technique[技术] by (71.8m points)

apache - Verifying Googlebot in .htaccess file

I have been investigate a bit. Will code below work? Not so easy to check.

RewriteEngine on
HostnameLookups Double  
RewriteCond %{REMOTE_HOST} (.googlebot.com) [NC] 
RewriteRule ^(.*)$ /do-something [L,R]

I worry the most for part

HostnameLookups Double 

It says in some place that works only in httpd.confg, vps, directory(not shure what this last means if not .htaccess but not saying in htaccess). Do you have knowledge about this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In .htaccess:

Order Allow, Deny

Allow from googlebot.com
Allow from search.msn.com
Allow from crawl.yahoo.net
Allow from baidu.com
Allow from yandex.ru
Allow from yandex.net
Allow from yandex.com

Maybe some other search engines would also be a good idea?

From Apace docs: http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow

...It will do a reverse DNS lookup on the IP address to find the associated hostname, and then do a forward lookup on the hostname to assure that it matches the original IP address. Only if the forward and reverse DNS are consistent and the hostname matches will access be allowed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...