302 redirect with netlify#
We have summarized how to implement 302 redirect with netlify.
What I want to achieve#
- When you access https://mtakagishi.com/,
- Japanese user:
302 redirect to /ja and the Japanese page is initially displayed.
- Other than Japanese:
302 redirect to /en and the English page is initially displayed.
netlify specifications#
The setting method is to place
_redirectsor writenetlify.tomlCan be branched by browser language. Use like
conditions = { Language = ["ja"] }Multiple routing settings are possible and interpreted from above.
If index.html exists directly under from, it will not be redirected. force=true is required when redirecting
Example configuration of netlify.toml#
netlify.toml#
[[redirects]]
from = "/"
to = "/ja/"
status = 302
conditions = { Language = ["ja"] }
force = true
[[redirects]]
from = "/"
to = "/en/"
status = 302
force = true
Reference URL#
Article information
- Post date:
2025-03-23
- author:
Mr. Takagi
Upon restarting the site update
Rebuilding the python environment