Skip to content

Conversation

@shigahi
Copy link
Collaborator

@shigahi shigahi commented Jan 22, 2026

Summary

Add support for configuring subdomain redirects, allowing users to redirect subdomains (e.g., www) to the main domain or vice versa.

Use Cases

  1. Redirect www.example.com to example.com
  2. Redirect example.com to www.example.com
  3. Redirect old subdomains to new locations

Changes

  • Add SubdomainRedirect interface with subdomain and redirectUrl fields
  • Add "Subdomain Redirects" section in Advanced Settings with add/remove functionality
  • Generate SUBDOMAIN_REDIRECTS configuration in Worker script
  • Implement redirect logic in fetchAndApply function that:
    • Checks if the request is for a subdomain of the main domain
    • Returns a 301 redirect if a matching redirect is configured
    • Preserves the pathname and query string in the redirect

Configuration Example

const SUBDOMAIN_REDIRECTS = {
  'www': 'https://example.com',
  'old': 'https://example.com/new-location',
};

Benefits

  • SEO consolidation (avoid duplicate content on www vs non-www)
  • Flexible domain management
  • Clean redirect handling with 301 status code

Closes #15

- Add SubdomainRedirect interface for configuring redirects
- Add UI for managing subdomain redirects in Advanced Settings
- Implement redirect logic in fetchAndApply function
- Support 301 redirects from subdomains to main domain or other URLs

Closes #15
@shigahi shigahi merged commit c833100 into master Jan 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add subdomain redirect support

2 participants