我遇到了一个似乎根本没有记录的问题。当您从 Jekyll 博客输入自定义 URL 时,您可以浏览站点目录:
http://example.com/category/article (显示文章) -> 如果有人输入http://example.com/category/ Jekyll 中没有引用,他可以找到这个:
我希望 Jekyll(或者我猜是 htaccess)只显示我实际发布的页面。也许会返回自定义 404 页面来重新路由用户。这里的主要问题是 Google 的 SEO,它索引了此类内容,而且很丑陋:)
最佳答案
这是因为您的文件夹中没有 index.html 文件。
杰基尔之道
在 github 页面上,您将收到 404 错误,而不是目录列表。
在其他类型的主机上,您可以使用 jekyll-redirect-from并制作一个像这样的 404.html 页面:
---
layout: default
title: 404 Not Foune
permalink: /404.html
redirect_from:
- /category/
- /other/folder/to/protect/
---
<h2>This is a 404 !</h2>
然后,这将创建重定向到 404 页面的/category/index.html 和/other/folder/to/protect/index.html 文件。
处理apache
.htaccess
Options -Indexes
ErrorDocument 403 /path/from/root/404.html
这很难看(为 403 禁止返回 404 页面),但它确实有效。
关于url - 禁止用户探索 Jekyll 的索引/与 Jekyll 一起探索索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28106095/