Skip to content

Add custom redirect rules (301/302) #32

Description

@shigahi

Summary

Add configurable URL redirect rules for SEO and URL migration purposes.

Background

When restructuring a site or changing URLs, 301 redirects are essential for maintaining SEO value. Commercial services like Bullet.so offer redirect management. This complements the existing subdomain redirect feature.

Proposed Configuration

redirectRules?: {
  from: string;      // e.g., "/old-page"
  to: string;        // e.g., "/new-page" or "https://example.com/page"
  permanent: boolean; // true = 301, false = 302
}[]

Implementation

Add redirect handling early in fetchAndApply:

const REDIRECT_RULES = [
  { from: '/old-url', to: '/new-url', permanent: true },
  // ...
];

// In fetchAndApply, before other routing:
for (const rule of REDIRECT_RULES) {
  if (url.pathname === rule.from) {
    const redirectUrl = rule.to.startsWith('http') 
      ? rule.to 
      : 'https://' + MY_DOMAIN + rule.to;
    return Response.redirect(redirectUrl, rule.permanent ? 301 : 302);
  }
}

UI Changes

Add "Redirect Rules" section in Advanced Settings:

  • List of redirect rules with add/remove buttons
  • Each rule has:
    • From path input
    • To path/URL input
    • Permanent redirect toggle (301 vs 302)

Use Cases

  • URL restructuring while preserving SEO
  • Migrating from another platform
  • Shortening URLs for marketing campaigns
  • Handling common typos/variations

References

  • Bullet.so redirect feature
  • Similar pattern to existing subdomainRedirects

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions