Trailing slashes and clean urls

0

According to the documentation, I understood that the page at /about would automatically try to redirect to /about/ when about.html returns 404. However it does not appear to be the case.

I tried with and without the following redirect rule:

{
    "source": "/<*>",
    "target": "/404",
    "status": "404",
    "condition": null
}

Source: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#trailing-slashes-and-clean-urls

boris13
質問済み 5年前1409ビュー
3回答
0
承認された回答

Hi boris13,

Without any redirect rules I'm seeing the following in my hugo website:
/welcome (200) since the file /welcome.html exists.
/about (404) redirects to /about/ which loads the page /about/index.html (200) since this file exists.
/test (404) redirects to /test/ which tries to load the page /test/index.html (404) since that file does not exist.

Note that using a redirect rule like:
{
"source": "/<*>"
"target": "/404"
"status": "404"
}

Will result in /test (404) -> /404 (404) -> /404/ (200). This is because /test.html and /404.html do not exist in my website, while /404/index.html does exist.

Does this correspond to what you are seeing in your website? If not, please send me a direct message with your App ARN and I'll take a look.

AWS
回答済み 5年前
0

Just to add a comment, it seems the opposite works.
If I generate pages as about.html (instead of about/index.html), both .../about and .../about/ work properly.

Edited by: boris13 on Apr 28, 2019 9:24 AM

boris13
回答済み 5年前
0

Thanks for the reply, this is was a clear answer and made me understand better the logic.

I was using a middleware which was matching non existing routes (such as /login instead of /login/) and was preventing the redirections to happen properly.

boris13
回答済み 5年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ