2013-07-07 76 views

回答

0

一个简单的解决办法就是使用密码保护使用.htaccess整个管理文件夹。

在您要锁定的文件夹中的.htaccess文件中输入以下内容。

AuthUserFile /absolute_path/to/.htpasswd 
AuthType Basic 
AuthName "Administration Area" 
Require valid-user 

然后使用htpasswd生成一个用户名和密码,生成的文件应该被存储在由/absolute_path/to/.htpasswd

指定的位置你也应该能够到.htaccess文件添加到您admin文件夹并选择用户代理和数据块存取这样:

RewriteEngine on 
RewriteCond %{HTTP_USER_AGENT} ^Googlebot [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Crawler 
# fill up with other user agents you would like to block here 
# and redirect to some other page 
RewriteRule ^(.*)$ http://example.com/404.html 
+0

我做我自己所以没有人可以访问管理区...我只是想隐藏文件夹从搜索引擎...谢谢:) –

+0

@MichaelSamuel - 我更新了答案。 –

0

这实在是令人生畏拿出所有的用户代理的LIS和记住,搜索代理值CA也是伪造的。

说了以下适用于大多数搜索引擎的工作:

启用mod_rewrite的,并通过httpd.conf的.htaccess,然后把这个代码在你.htaccessDOCUMENT_ROOT目录:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_USER_AGENT} (googlebot|adsbot-google|bingbot|msnbot|psbot|gigabot|twitterbot|linkedinbot|yahoo-mmcrawler|pingdom\.com_bot) [NC] 
RewriteRule ^folder-to-hide/ - [L,F,NC] 
相关问题