Skip to content

ipfs/go-ipfs-redirects-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f256800 · Feb 16, 2025

History

85 Commits
Oct 22, 2024
Sep 22, 2022
Sep 9, 2020
Sep 22, 2022
Oct 22, 2024
Feb 16, 2025
Oct 22, 2024
Oct 22, 2024
Aug 11, 2022
Oct 22, 2024
Oct 22, 2024

Repository files navigation

IPFS _redirects File Parser

This is a parser for the IPFS Web Gateway's _redirects file format.

Specification

This repository implements Web _redirects File Specification from https://specs.ipfs.tech/http-gateways/web-redirects-file/.

For historical discussion see ipfs/specs#290 and IPIP-0002: _redirects File Support on Web Gateways.

Format

Currently only supports from, to and status.

from to [status]

Example

# Implicit 301 redirects
/home              /
/blog/my-post.php  /blog/my-post
/news              /blog
/google            https://www.google.com

# Redirect with a 301
/home         /              301

# Redirect with a 302
/my-redirect  /              302

# Redirect with wildcard (splat placeholder)
/splat/* /redirected-splat/:splat 301

# Redirect with multiple named placeholder
/posts/:year/:month/:day/:title  /articles/:year/:month/:day/:title  301

# Show a custom 404 for everything under this path
/ecommerce/*  /store-closed.html  404

# Single page app rewrite (SPA, PWA)
/*    /index.html   200

Notes for contributors

  • make all builds and runs tests
  • FUZZTIME=1m make fuzz runs fuzzing for specified amount of time

Credit

This project was forked from tj/go-redirects. Thank you TJ for the initial work. 🙏