π Enhancement: Sites and Functions Domain Direction Preference - WWW Redirect Configuration
- 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
Assessment
This issue has not been assessed yet.