AWS Route 53
Route 53 to redirect to external domain use Amazon API Gateway
when you search Route 53 redirection you can see several approaches
use Route 53 + S3 Bucket this case only works when you redirect to the specific domain without a path.
use Route 53 + API Gatreway + AWS Lambda You really don't need this if you want to redirect to a specific target.
I'll tell you real-world case
I own devserum.com
domain, and when people type URL medium.devserum.com
I wanted to redirect to mediu.com/devserum.
Route 53 + S3 Bucket
combination.
Route 53 + S3 Bucket
combination.but this case not working with Route 53 + S3 Bucket
combination.
because for this combination you should make exactly the same S3 bucket name with a redirection target.
if you want direct test.com
yes it's possible. but if you want to test.com/some-path
not possible because S3 Bucket name does not allow path.
Route 53 + API Gateway + AWS Lambda combination.
it's too over egineering.
you don't need AWS Lambda for this.
Solution : Route 53 + API Gateway
go to API Gateway Main Page
click 'Create API' button
click REST API's 'Build' button (not private)
type API name (could be anything) & click 'create API' button
click 'actions' button' and 'Create Method' button
Create 'GET' method & integration Type 'Mock'
after that if you click 'GET' method you can see this screen. click 'Integration Request'
and follow steps of bellow picture
at step 4, you should replace vallue like this
{ "statusCode": 301, } #set($context.responseOverride.header.location = "https://medium.com/devserum")
now go to
Methods Response
click
Add inetegration response
add 301 status
add header 'Location'
now go to
Integration Response
delete 200 status
click 'Add Integration Response'
301 response must be default like screen shot
after that click 'Header Mappings'
and add header key
Location
and valueintegration.response.header.Location
test & deploy
after that, you should be mapping
custom domain names
->API mappings
that you just release
Last updated
Was this helpful?