Advertisement
fakesamgregory

Cloudfront Functions — Redirect Rules

Aug 27th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function handler(event) {
  2.     var request = event.request;
  3.  
  4.     if (request.uri !== "/" && (request.uri.endsWith("/") || request.uri.lastIndexOf(".") < request.uri.lastIndexOf("/"))) {
  5.           if (request.uri.endsWith("/")) {
  6.              request.uri = request.uri.concat("index.html");
  7.           } else {
  8.              request.uri = request.uri.concat("/index.html");
  9.           }
  10.      }
  11.  
  12.     return request
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement