Do you want to change the URL of a page as it is shown in search engine results,then use a server-side 301 redirects. This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.
If you see a message that your site is not indexed, it may be because it is indexed under a different domain. For example, if you receive a message that http://example.com is not indexed, make sure that you’ve also added http://www.example.com to your account (or vice versa), and check the data for that site.
What is 301 redirects and why it is useful ?
You’ve moved your site to a new domain, and you want to make the transition as seamless as possible. People access your site through several different URLs. If, for example, your home page can be reached in multiple ways – for instance, http://example.com/home, http://home.example.com, or http://www.example.com – it’s a good idea to pick one of those URLs as your preferred (canonical) destination, and use 301 redirects to send traffic from the other URLs to your preferred URL.You’re merging two websites and want to make sure that links to outdated URLs are redirected to the correct pages.
Now how can you do 301 redirects in AWS ?
Unfortunately In AWS Route 53, there is no native way to do this, but luckily it’s a couple of simple steps away and you also get to learn a little about web site hosting on AWS S3 (Simple Storage Service) at the same time.
Here is a blog how to use Amazon S3 in Simple Steps click here
Let me clarify here,,Amazon S3 has a free tier usage for 1year where you can get upto 5gb standard storage
20,000 Get Requests , 2,000 Put Requests ,15 gb of Data Transfer every month
Even after the free usage 0.004$ per 10,000 HTTP GET requests per month
Configuring your AWS S3 Buckets :
Firstly,Login to your AWS account and then open the S3 dashboard from console home :
From S3 dashboard and click on “Create Bucket”
Enter the Bucket Name with your domain such as ” www.example.com ” and click on Create on your left side
Once it is created succesfully you can find it in your buckets
Once created you can click on the bucket where you can find upload and all other stuff.
From properties move on to static website hosting
Under static website hosting you need to click on “Redirect requests” and then write the bucket name you want to target,,for example non-www version,here in my case i am redirecting from www to non-www you can see at this link www.nectarspot.com
Now half of the job is done,now you need to configure the Route53.
Under Route53 go to hosted zones where you can find your domain which is mapped to some instance or apps.And then move to your sub-domain of www version and keep type as “A-IPV4 address” and the alias from “No” to “Yes”
Now Click in the Alias Target field which brings up a droplist. It may take up to 20 or more seconds to populate the list. Under the S3 website endpoints you will see the one you’ve created. Select that and click the Create button at the bottom:
Sit Back and relax now your job is done,Now test it on your site by www.example.com is redirecting to example.com,Now once it is done click on inspect element and then go to network and refresh the page with www.example.com you will now redirect to example.com and you can find status 200 ” ok ” for example.com and 301 “Moved Permanenetly ” for www.example.com