Simple Domain Redirect On AWS
Assuming you have some domain configured on AWS using Route 53: example.eu
And now you want to redirect all traffic from example.eu to blog.example.eu
Step 1: Create S3 Bucket
- S3 Console -> Create bucket
- Bucket name:
example.eu
(must match your domain exactly) - Keep all default settings -> Create bucket
Step 2: Configure S3 for Redirect
- Select your bucket -> Properties tab
- Static website hosting -> Edit
- Enable static website hosting
- Hosting type: Redirect requests for an object
- Host name:
blog.example.eu
- Protocol:
https
- Save changes
Copy the S3 website endpoint (e.g.,
http://example.eu.s3-website-us-east-1.amazonaws.com
)
Step 3: Request SSL Certificate
Important: Must be done in us-east-1 region
- Certificate Manager -> Request certificate
- Domain name:
example.eu
- Validation: DNS validation
- Request certificate
- Create records in Route 53 (button will appear)
- Wait for “Issued” status (5-10 minutes)
Step 4: Create CloudFront Distribution
- CloudFront Console -> Create distribution
- Origin domain: Paste your S3 website endpoint from Step 2 (e.g.,
http://example.eu.s3-website-us-east-1.amazonaws.com
) - Protocol: HTTP only
- Viewer protocol policy: Redirect HTTP to HTTPS
- Alternate domain names:
example.eu
- SSL certificate: Select your certificate from Step 3
- Create distribution
Wait 15-20 minutes for deployment
Step 5: Update Route 53
- Route 53 -> Hosted zones -> example.eu
- Create record
- Record name: Leave empty
- Record type: A
- Alias: Yes
- Route traffic to: CloudFront distribution
- Select your distribution
- Create records
Wait 5~20 minutes, then test:
- Opening http://example.eu
-> should redirect to
https://blog.example.eu
- Opening https://example.eu
-> should redirect to
https://blog.example.eu