質問編集履歴

1

ソースコードを追加

2020/05/21 01:54

投稿

nora96
nora96

スコア0

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,13 @@
18
18
 
19
19
 
20
20
 
21
+ ### ソースコード
21
22
 
23
+ 'use strict';
24
+
25
+ module.exports.redirect = (event, context, callback) => { const request = event.Records[0].cf.request;
26
+
27
+ if (request.uri.indexOf('/dir1/dir2/{YYYYMMDD}.html') === -1) { const uri = request.uri.replace('/dir1/dir2/{YYYYMMDD}.html', '/dir1/dir2/{YYYYMMDD}/'); const redirect = { status: '302', statusDescription: 'Found', headers: { location: [{ key: 'Location', value: uri, }] } }; callback(null, redirect); }
22
28
 
23
29
 
24
30
 
@@ -26,4 +32,4 @@
26
32
 
27
33
 
28
34
 
29
- Node.js
35
+ CloudFront AWS Lambda Node.js