Jokerius
Jokerius

Reputation: 1320

How to redirect from subdomain to url in domain using AWS Route53

Need redirect from blog.example.com to www.example.com/blog using AWS Route53, preserving queries.

Also need to set up smart redirects i.e. blog.example.com/articles/slug to www.example.com/blog/slug

Need to avoid double redirects too.

Upvotes: 0

Views: 782

Answers (2)

JamesFrost
JamesFrost

Reputation: 769

This isn't possible with Route53.

I would recommend instead using an Application Load Balancer. You can create rules that match based on host and path, and route to specific target groups.

Upvotes: 1

Jokerius
Jokerius

Reputation: 1320

Managed to do this with pointing subdomain to Load Balancer in Route53 (A record) and Nginx configuration:

server {
    server_name blog.example.com;
    rewrite ^/articles/(.*) https://www.example.com/blog/$1 permanent;

    return 301 https://www.example.com/blog/blog$request_uri;
}

Upvotes: 0

Related Questions