简体   繁体   English

如何使用 AWS Route53 从子域重定向到域中的 url

[英]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.需要使用 AWS Route53 从 blog.example.com 重定向到www.example.com/blog ,保留查询。

Also need to set up smart redirects ie blog.example.com/articles/slug to www.example.com/blog/slug还需要设置智能重定向,即 blog.example.com/articles/slug 到www.example.com/blog/slug

Need to avoid double redirects too.也需要避免双重重定向。

This isn't possible with Route53. Route53 无法做到这一点。

I would recommend instead using an Application Load Balancer . 我建议改为使用 Application Load Balancer You can create rules that match based on host and path, and route to specific target groups.您可以创建基于主机和路径匹配的规则,并路由到特定目标组。

Managed to do this with pointing subdomain to Load Balancer in Route53 (A record) and Nginx configuration:通过将子域指向 Route53(A 记录)和 Nginx 配置中的负载均衡器,设法做到这一点:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM