Apache 如何使用htaccess从搜索引擎隐藏文件夹

Apache 如何使用htaccess从搜索引擎隐藏文件夹,apache,security,.htaccess,mod-rewrite,Apache,Security,.htaccess,Mod Rewrite,有没有办法使用htaccess从搜索引擎中隐藏管理员文件夹?我知道可以使用robots.txt完成,但robots.txt本身很容易访问 谢谢一个简单的解决方案是使用.htaccess对整个管理文件夹进行密码保护 在要锁定的文件夹中的.htaccess文件中输入以下内容 AuthUserFile /absolute_path/to/.htpasswd AuthType Basic AuthName "Administration Area" Require valid-user 然后使用生成用

有没有办法使用htaccess从搜索引擎中隐藏管理员文件夹?我知道可以使用robots.txt完成,但robots.txt本身很容易访问


谢谢

一个简单的解决方案是使用
.htaccess
对整个管理文件夹进行密码保护

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

AuthUserFile /absolute_path/to/.htpasswd
AuthType Basic
AuthName "Administration Area"
Require valid-user
然后使用生成用户名和密码,生成的文件应存储在
/absolute\u 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

提出一个包含所有用户代理的lis,并记住搜索代理的价值也可能被伪造,这真是令人望而生畏

话虽如此,以下内容适用于大多数搜索引擎:

通过
httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放入
文档根目录下的
.htaccess

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]

我自己进行身份验证,因此没有人可以访问管理区域…我只想对搜索引擎隐藏文件夹…谢谢:)