mirror of
				https://github.com/eledio-cloud/standard-redirects-for-cloudfront.git
				synced 2025-10-31 00:12:56 +01:00 
			
		
		
		
	reverse index.html implemented
This commit is contained in:
		
							
								
								
									
										21
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								index.js
									
									
									
									
									
								
							| @@ -20,13 +20,26 @@ const http = require('http'); | ||||
|  | ||||
| exports.handler = (event, context, callback) => { | ||||
|   const request = event.Records[0].cf.request; | ||||
|      | ||||
|   if (request.uri.endsWith('/')) { | ||||
|    | ||||
|   let prefixPath; // needed for 2nd condition | ||||
|  | ||||
|   if (request.uri.match('.+/$')) { | ||||
|     request.uri += 'index.html'; | ||||
|     callback(null, request); | ||||
|   } else if (request.uri.match('/[^/.]*$')) { | ||||
|   } else if (prefixPath = request.uri.match('(.+)/index.html')) { | ||||
|     const response = { | ||||
|       status: '302', | ||||
|       status: '301', | ||||
|       statusDescription: 'Found', | ||||
|       headers: { | ||||
|         location: [{ | ||||
|           key: 'Location', value: prefixPath[1] + '/', | ||||
|         }], | ||||
|       } | ||||
|     }; | ||||
|     callback(null, response); | ||||
|   } else if (request.uri.match('/[^/.]+$')) { | ||||
|     const response = { | ||||
|       status: '301', | ||||
|       statusDescription: 'Found', | ||||
|       headers: { | ||||
|         location: [{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user