2

我在根目录和单独的目录中有 HTML 文件,这些文件通过 SSI 包含到其他页面中。

  1. 如何禁止通过直接 URL 打开此 HTML 文件,但同时仍让 SSI 可以访问它们?.htaccess 还是别的什么?一般可以吗?

  2. 如何禁止为搜索引擎机器人抓取此 HTML 文件?如果我将它们包含在其他页面的 SSI 中,但在站点上没有任何直接链接到它们,搜索引擎机器人会看到它们吗?

4

1 回答 1

3

创建 robots.txt 并添加以下内容:

User-agent: * 
Disallow: /foldername-you-want-to-disallow/ # hides all files in this directory from bots
Disallow: /hidden.html # hides a specific file in the root dir from bots
Disallow: /foldername/hidden.html # hides a specific file in a subdir from bots

或者

您可以创建一个 .htaccess 文件并将其上传到您要隐藏的目录中。包括以下这些:

Options -Indexes

Order deny,allow
Deny from all

您仍然可以通过 SSI 调用它们,但任何 http 直接请求都将被阻止。

于 2012-08-15T04:16:27.877 回答