我在根目录和单独的目录中都有 HTML 文件,这些文件通过 SSI 包含到其他页面中。
如何禁止通过直接 URL 打开此 HTML 文件,但仍让 SSI 在同一时刻可访问它们? .htaccess 还是其他什么?一般情况下可以吗?
如何禁止搜索引擎机器人抓取此 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/