var PORTAL_URL = "https://jobs.appone.com/seahaven"; // Retired local job pages. Redirect before the directory-index rewrite so // these paths never fall through to the HTML stubs in S3. var RETIRED_JOB_URIS = { "/careers/dispatcher": 1, "/careers/dispatcher/": 1, "/careers/dispatcher/index.html": 1, "/careers/scheduling-coordinator": 1, "/careers/scheduling-coordinator/": 1, "/careers/scheduling-coordinator/index.html": 1, "/careers/traveling-maintenance-assistant": 1, "/careers/traveling-maintenance-assistant/": 1, "/careers/traveling-maintenance-assistant/index.html": 1 }; function handler(event) { var request = event.request; var uri = request.uri; // CloudFront does not normalize URI case. The S3 keys are lowercase. if (RETIRED_JOB_URIS[uri.toLowerCase()]) { return { statusCode: 301, statusDescription: "Moved Permanently", headers: { location: { value: PORTAL_URL } } }; } var last = uri.substring(uri.lastIndexOf("/") + 1); // S3 OAC has no directory index. default_root_object only covers "/". // Keep the browser URL; rewrite the origin key to …/index.html. if (uri.endsWith("/")) { request.uri = uri + "index.html"; } else if (last.length > 0 && last.indexOf(".") === -1) { request.uri = uri + "/index.html"; } return request; }