html - 禁止打开和抓取 HTML 文件

标签 html seo search-engine bots web-crawler

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

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

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

最佳答案

创建 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 直接请求都将被阻止。

关于html - 禁止打开和抓取 HTML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11963982/

相关文章:

html - 导航栏中的中心 Logo

html - 将背景图像定位到其自身元素的边距中 - 这可能吗?

html - 将美元前缀添加到 Bootstrap 输入框

seo - 每页 2 个版本

.htaccess - 仅通过 HTTP 访问网站,除了 2 个页面

seo - 谷歌附加链接搜索框

SEO 和 301 重定向 - 它们可以有相对路径还是必须是绝对路径?

javascript - 当我使用Web SQL时,我遇到了麻烦

seo - 加载谷歌字体的最佳方式 <link/> , @import 或 javascript

c# - 在类似 eBay 的系统中使用的最佳搜索引擎 (.NET)