3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AmplifyのSAPリダイレクト設定

Posted at

Amplify Gen2ホスティング環境での設定備忘録です。

SPAリダイレクト設定

AmplifyでSPA(Single Page Application)のWebサイトでルート以外のページにアクセスする場合、リダイレクト設定が必要となります。

Amplifyのアプリから、[ホスティング] > [リライトとリダイレクト] > [リダイレクトを管理] から設定を行います。

image.png

初期値では、index.htmlにリダイレクトされるように設定されています。

リダイレクトの設定

次の記事の内容に従ってリダイレクト設定を書き換えます。

が、コピーしてそのまま貼り付けても次のようにエラーになって保存できません。(2025-09-26現在。そのうち修正されると思いますが。。。)

image.png

原因と対策

原因は単純な話で、サンプルに記述されているsourceの値に含まれる正規表現内のバックスラッシュ \はエスケープが必要です。'\'と指定することでエラーの回避ができます。

[
  {
    "source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json|webp)$)([^.]+$)/>",
    "status": "200",
    "target": "/index.html",
    "condition": null
  }
]

早いところ公式記事は修正してもらえるとうれしい。。。

さいごに

今回は、Amplify Gen2のリダイレクト設定についての備忘録を書かせていただきました。

どなたかのお役に立てると幸いです。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?