Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Redirect root domain to www in aws route 53 without S3

I want to redirect my root domain to www.domain.com. The site is published using s3 CloudFront and route53.

I have seen a lot of docs on how to redirect using s3, but I cannot do it because there's already a bucket with my root domain somewhere. So I cannot create a bucket with my root domain as the name. Also, I doubt whether this s3 redirection will work for the https request.

I haven't seen any blog on redirecting without using the s3 bucket.

So how can I redirect an HTTP/https root domain to www subdomain in aws.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You cannot redirect using Route 53 (it is a DNS configuration service afterall, whereas redirects are a HTTP operation).

If you cannot use S3, another solution could be to use use CloudFront with a Lambda@Edge function.

If the hostname is not the www domain you could perform the redirect to the www domain.

The function might look similar to the below

def lambda_handler(event, context):
 
    request = event["Records"][0]["cf"]["request"]
    response = event["Records"][0]["cf"]["response"]
    # Generate HTTP redirect response with 302 status code and Location header.
    
    if request['headers']['host'][0]['value'] != 'www.example.com':
     
        response = {
            'status': '302',
            'statusDescription': 'Found',
            'headers': {
                'location': [{
                    'key': 'Location',
                    'value': 'https://www.example.com/{}' .format(request['uri'])
                }]
            }
        }
     
    return response
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!