Comments (1)
Would something like this work for your use case?
function handler(event) {
var request = event.request;
var uri = request.uri;
var host = request.headers.host.value;
if(!uri.includes('/partners/')){
uri = uri.toUpperCase()
var response = {
statusCode: 302,
statusDescription: 'Found',
headers:
{ "location": { "value": `https://${host}/partners${uri}` } }
}
return response;
}
return request;
}
This function takes the URI path (/aapo) and checks if it does not contain /partner/
. If not, the function will :
- Make the URI path uppercase (/AAPO). Not sure if this is required, but it was upper case in your example.
- Issue a 302 redirect to the new URL using the same host header as the base host for the URL and adds the
/partner/
to the URI path.
If the URI path contains /partner/
the function will return the URL as is (no-op).
from amazon-cloudfront-functions.
Related Issues (20)
- Redirect preserve query string HOT 11
- 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.