You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS是否支持URL掩码?场景与需求详述

Does AWS support URL masking for redirecting demo2.example.com to demo1.example.com/admin?

Absolutely, AWS supports URL masking (also called hidden redirects) for your exact scenario! This lets users visit demo2.example.com and see content from demo1.example.com/admin while keeping demo2.example.com in their browser's address bar. Below are two reliable implementation approaches tailored to your setup:

Option 1: S3 Static Website Hosting + Route 53 (Simple Setup)

Perfect for straightforward redirect needs, with optional HTTPS support:

  • Create an S3 bucket named demo2.example.com (the bucket name must match your target subdomain exactly—this is a requirement for S3 static site aliases).
  • Enable "Static website hosting" for the bucket, select "Redirect requests to another host name", and enter https://demo1.example.com/admin as the target. Choose "Hidden (301 Permanent)" or "Hidden (302 Temporary)" for the redirect type—this is what enables URL masking (the browser address bar won’t update to the demo1 path).
  • In Route 53, create an Alias record for demo2.example.com pointing to your S3 bucket’s static website endpoint.
  • HTTPS Note: To serve demo2.example.com over HTTPS, wrap the S3 bucket with a CloudFront distribution, attach an SSL certificate (from AWS Certificate Manager, ACM) for demo2.example.com, then point your Route 53 record to the CloudFront domain instead of S3 directly.

Option 2: CloudFront Reverse Proxy (Flexible & HTTPS-Friendly)

Ideal if you need caching, HTTPS, or more control over traffic to your admin panel:

  • Create a new CloudFront distribution:
    • Set the Origin domain to demo1.example.com, and enter /admin as the Origin path (this tells CloudFront to fetch content directly from the admin folder of your EC2-hosted site).
    • Under "Settings", add demo2.example.com as a Alternate domain name (CNAME).
    • Attach an SSL certificate for demo2.example.com (must be issued in the us-east-1 AWS region via ACM—CloudFront requires certificates from this region).
  • In Route 53, create an Alias record for demo2.example.com pointing to your new CloudFront distribution’s domain.
  • Verify your EC2 web server (e.g., Nginx, Apache) allows requests from demo2.example.com—you might need to update server blocks or CORS settings if your admin panel uses frontend assets with absolute paths.

Quick Checks

  • Confirm your demo1.example.com EC2 instance is running and accessible (you mentioned it’s active, so this should be covered).
  • For CloudFront, double-check the origin path to avoid 404 errors—if your admin panel uses hardcoded paths to demo1.example.com, you may need to adjust your web server to rewrite requests from demo2.example.com correctly.

内容的提问来源于stack exchange,提问作者amitava deb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:56:19