拒绝从用户访问.xml但允许机器人抓取

时间:2017-11-25 11:23:28

标签: xml block bots

如何阻止用户直接从.httacess访问.xml文件,但允许google,msn或yahoo机器人仍然抓取并访问该文件?

我的httacess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^sitemap.xml$ /sitemap.php [L]
</IfModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

1 个答案:

答案 0 :(得分:0)

错误...首先询问所有机器人所有者他们的机器人将从中查询您的网站的完整IP地址列表,以便您只允许这些IP获得响应。

他们会拒绝回答(并且忽略这个问题),原因有很多,包括他们不喜欢他们的机器人得到的结果与普通用户不同,因为它实际上是试图操纵他们认为你提供的内容不是实际上提供。所以你将永远坚持这一步,不需要知道下一步。