Domain Redirects with Cloudflare
This guide covers setting up and managing domain redirects using Cloudflare’s services.
Types of Redirects
Three main redirect types are used:
301: Permanent redirect
302: Temporary redirect
308: Permanent redirect (preserves HTTP method)
Basic Setup
Page Rules Configuration
Access through: Dashboard > Websites > Your Domain > Page Rules
Common redirect patterns:
Domain redirect:
example.com/* → newdomain.com/$1
Subdomain redirect:
blog.example.com/* → newdomain.com/blog/$1
Path redirect:
example.com/old/* → example.com/new/$1
DNS Configuration
Required DNS records:
A record:
Name: @
Content: 192.0.2.1
Proxy: Enabled
Subdomain A record:
Name: subdomain
Content: 192.0.2.1
Proxy: Enabled
Implementation Examples
Domain Redirect
Pattern: olddomain.com/*
Type: 301 Permanent
Destination: https://newdomain.com/$1
Subdomain Redirect
Pattern: sub.olddomain.com/*
Type: 301 Permanent
Destination: https://newdomain.com/sub/$1
WWW Redirect
Pattern: www.domain.com/*
Type: 301 Permanent
Destination: https://domain.com/$1
Required Settings
- SSL/TLS:
Enable HTTPS
Set encryption mode to Full/Full (strict)
- Page Rules Order:
Specific rules first
General rules last
Testing
Test redirects on:
Multiple browsers
Desktop and mobile devices
Private browsing mode
Common Issues
DNS Problems
Verify DNS record configuration
Check Cloudflare proxy status
Confirm DNS propagation
Mobile Issues
Check DNS resolver settings
Clear device DNS cache
Verify SSL certificates
Browser Issues
Clear browser cache
Check DNS settings
Verify redirect chain
Maintenance
Regular checks for:
404 errors
SSL certificate status
Redirect performance
Additional Notes
Monitor traffic patterns
Check redirect chains periodically
Update DNS settings as needed
This guide covers basic to advanced redirect configurations in Cloudflare. Adjust settings based on specific requirements.