-
-
Notifications
You must be signed in to change notification settings - Fork 463
Question: How to redirect www to non-www with AWS #633
Comments
I think you can follow here for now: https://github.com/serverless-nextjs/serverless-next.js#i-was-expecting-for-automatic-subdomain-redirection-when-using-the-domaintype-wwwapex-input. Basically you need to manually create new S3 bucket and CloudFront distribution (for HTTPS redirect) and some new Route53 A record. In the future it's possible to support it in this component within the same CF distribution, but we would need to make a couple of changes:
|
Now that redirects are done (#587 (comment)) we could leverage similar code to do a redirect from a domain name to another in the Lambda@Edge itself. Probably create another input like Although it's just a bit costlier than the S3 bucket redirect (due to use of Lambda@Edge compute), it has a few advantages:
Caveat: currently only the default cache behavior ( |
thanks for your update. I have as recommended manually create new S3 bucket and CloudFront distribution and some new Route53 A record. I have 2 CloudFront distribution :
It works well. Now, if I deploy again via I just removed |
Yeah, I think you may need to set |
I've released the PR: #639 which can support this domain-level redirect in the Lambda@Edge itself. If you wish, you can try this method - please refer to the README for more details. |
@dphang which version of the component should be used to do that? |
With AWS, Can you guide me to redirect www to non-www to avoid duplicate content?
Should we create a s3 bucket and a new Cloud front distribution? (https://www.pbxdom.com/how-redirect-non-www-to-www-with-amazon-cloud-front-route-53-and-s3)
or, can we set it up in the
serverless.yml
file?Thanks!
The text was updated successfully, but these errors were encountered: