appwrite / appwrite/appwrite

πŸš€ Enhancement: Sites and Functions Domain Direction Preference - WWW Redirect Configuration

Open
#9,912 0 comments 0 reactions 0 assignees View on GitHub
product / functions
Dominant language
TypeScript
Stars
57.4k
Forks
5.7k
Avg merge
14h 50m
Merged PRs (30d)
276

Description

### πŸ”– Enhancement description

Add domain direction preference settings for Appwrite Sites and Functions, allowing users to configure how www and non-www domains are handled with automatic redirect options.

**πŸš€ Feature Overview**
**Domain Direction Options:**
- **Allow WWW & non-WWW** - Both versions work independently (current behavior)
- **Redirect to www** - Automatically redirect non-www to www version
- **Redirect to non-WWW** - Automatically redirect www to non-www version

**Scope:**
- Static Sites (Appwrite Sites)
- Cloud Functions with custom domains
- Per-project configuration
- HTTP 301 permanent redirects for SEO

### 🎀 Pitch

**Why implement this:**
- **πŸ” SEO Optimization**: Prevents duplicate content penalties from search engines
- **πŸ“Š Analytics Consistency**: Unified traffic tracking across domain variants
- **πŸ‘₯ User Experience**: Consistent branding and URL structure
- **🏒 Professional Setup**: Standard requirement for production websites

**Use Cases:**
- **Marketing Sites**: Companies needing consistent brand URLs (www.company.com)
- **SaaS Applications**: Apps preferring clean URLs without www (app.com)
- **SEO-Critical Sites**: Blogs and content sites requiring unified domain authority
- **Enterprise Deployments**: Organizations with strict URL policies

**πŸ”§ Implementation Example**
```javascript
// Configure domain direction for a site
await sites.updateDomainSettings(siteId, {
domainDirection: 'redirect-to-www', // or 'redirect-to-non-www', 'allow-both'
customDomain: 'example.com'
});

// Configure for functions
await functions.updateDomainSettings(functionId, {
domainDirection: 'redirect-to-non-www',
customDomain: 'api.example.com'
});
```

**πŸŽ›οΈ UI Configuration**
```
Domain Settings
β”œβ”€β”€ Custom Domain: example.com
└── WWW Preference:
β—‹ Allow both www and non-www (current)
β—‹ Redirect to www (www.example.com)
● Redirect to non-www (example.com)
```

**πŸ”’ Technical Implementation**
- **301 Redirect**: Permanent redirects for SEO preservation
- **Header Injection**: Automatic redirect headers at edge level
- **DNS Compatibility**: Works with existing CNAME/A record setups
- **Performance**: Zero impact on primary domain performance

**πŸ”„ Migration**
- **Default Behavior**: Existing domains continue with "Allow both" setting
- **Opt-in Configuration**: Users can enable redirects when needed
- **No Breaking Changes**: Current setups remain functional

**πŸ“Š Expected Benefits**
- **Improved SEO**: Consolidated domain authority and rankings
- **Better Analytics**: Unified traffic data and user tracking
- **Professional URLs**: Consistent brand presentation
- **Reduced Confusion**: Single canonical URL for all users

**🌟 Competitive Advantage**
Most static hosting providers (Netlify, Vercel) offer this as a standard feature. Adding this would make Appwrite Sites more competitive for production deployments and professional websites.

This enhancement addresses a common production requirement that developers frequently request when deploying customer-facing applications.

### πŸ‘€ Have you spent some time to check if this issue has been raised before?

- [x] I checked and didn't find similar issue

### 🏒 Have you read the Code of Conduct?

- [x] I have read the [Code of Conduct](https://github.com/appwrite/.github/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.