Comments (2)
Hey, @719media, they kind of have an example at the redirect-based-on-country
folder.
I did a quick rewrite, and I assume this is what you are looking for?
Please do verify the output of the host
before deploying this to production to be sure you get the correct value.
function handler(event) {
var host = event.request.headers.host.value;
if (host !== 'example.com') {
return event.request;
}
return {
statusCode: 301,
headers: {
location: {
value: 'https://www.example.com'
}
}
};
}
I can create a PR for an example folder if that is something people find useful.
Cheers 🥂
from amazon-cloudfront-functions.
Ya, that's more or less what I came up with. I was just looking for the example's presence from library author as proof that this should be done at this (the cloudfront function) level (vs. on the Origin Request of lambda@edge for caching purposes). Best practices and all.
Thanks for the response!
from amazon-cloudfront-functions.
Related Issues (20)
- Redirect preserve query string HOT 11
- URL redirect/rewrite HOT 1
- Additional "s" in the folder path in the following command HOT 1
- Please provide an example with a simple cookie manipulation HOT 8
- Can AWS Parameter Store variables or secrets be used in CloudFront functions? HOT 6
- x-frame-options works but not x-xss-protection HOT 1
- How can I redirect with a huge list of urls? HOT 2
- Unable to use CloudFront Function "Test" Feature with host.value
- Use of crypto module? HOT 1
- Using cloudfron functions to remove server header HOT 3
- redirect on response HOT 3
- Unable to get clientIP HOT 1
- How to make a rewrite? HOT 1
- Verify cognito jwt with cloudfront function
- Response interceptor
- `Date` object has no `toUTCString` HOT 1
- anti-hotlinking with referer header
- url redirect adding multiple path HOT 1
- Decrypt a Cookie HOT 1
- Redirection problem with Nextjs application deployed on aws s3 and cloundfront as static application
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-cloudfront-functions.