In this article, we are going to learn redirect requests for your bucket’s website endpoint to another bucket or domain. Simple Storage Service, aka S3, is a block storage service offered by AWS. It is the most widely used, go-to storage service for AWS users. It provides high availability, security, easy integration with many AWS services, and the ability to host static websites. S3 also has a lesser-known feature where we can redirect requests from an S3 URL to any other domain. In this tutorial, we will create an S3 bucket and configure it to redirect requests to another domain. This is a free feature and you will not have to pay any money. Kindly refer to our related AWS guides: Creating IAM Users, Adding MFA and Policies on AWS, how to manage cost with AWS Budgets, how to deploy an Angular App to AWS S3, how to deploy a React App to AWS S3, and how to copy a server from S3 and vice-versa.
Setting up your AWS S3 bucket for website hosting.
- Sign in to the AWS Management Console.
- Navigate to AWS S3 dashboard.
This is the S3 dashboard where you can see the S3 buckets created in your account. Click on Create bucket to create your S3 bucket for website hosting.
The first option when creating the S3 bucket is to give it a name. Note here that your bucket name should be unique across All the S3 buckets in the world, so, if you try to keep common names, you might get some conflicts. See S3 bucket naming rules. Choose a unique name for your bucket. The next option is the AWS region. Choose a region closest to your location.
You can leave all the other parameters as default and click on the Create Bucket button at the end of the page.
You can now see your S3 bucket in the list. Click on the bucket name.
Go to the properties tab.
Now scroll down to find the Static website hosting property. Click edit.
Choose the enable the static website hosting. Choose the redirect requests option and enter the hostname to which you want to redirect your requests. You can enter any website here for our example I have used http://www.google.com. Choose the HTTP or HTTPS protocol and click on save changes.
Finally, you can click on the website endpoint of your S3 bucket and see that it is now redirecting your requests to the hostname you have entered.
You will now be redirected to the hostname website that you entered in the previous section.
With this, we have come to an end to this tutorial. I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.