首页 > 解决方案 > TYPO3 10 StaticRoute 返回 404 状态码

问题描述

我在 TYPO3 v10 中为我的 robots.txt 使用 staticText 路由(使用默认的 .htaccess 文件)。文本按预期交付,但标题中的 StatusCode 是 404。我不知道如何解决这个问题,因为 staticText 路由中没有设置 statusCode 的选项。

这是我的路线代码(如文档中所述:https ://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/SiteHandling/StaticRoutes.html ):

routes:
  -
    route: robots.txt
    type: staticText
    content: |
    Sitemap: https://example.com/sitemap.xml
    User-agent: *
    Allow: /
    Disallow: /forbidden/

标签: typo3typo3-10.x

解决方案


仔细查看文档。

在 YAML 文件中,缩进是关键。您必须缩进您的多行内容(以“站点地图:...”开头)。

routes:
  -
    route: robots.txt
    type: staticText
    content: |
      Sitemap: https://example.com/sitemap.xml
      User-agent: *
      Allow: /
      Disallow: /forbidden/

https://www.w3schools.io/file/yaml-multiline-strings/


推荐阅读