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:
		
							
								
								
									
										29
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								README.md
									
									
									
									
									
								
							| @@ -2,6 +2,31 @@ | ||||
|  | ||||
| A Lambda@Edge function that implements standard web server redirects: | ||||
|  | ||||
| URIs ending with a slash (e.g. "/something/") are "internally" redirected to "/something/index.html". | ||||
| URIs ending with a slash (e.g. "/something/") are "internally" redirected to "/something/index.html", i.e. the browser sees "/something/" but on the server-side the content is taken from "/something/index.html". | ||||
|  | ||||
| URIs without a suffix (and not ending with a slash) will redirect with an HTTP status 301 Moved Permanently to the same URL with a slash appended. | ||||
| URIs without an extension (and not ending with a slash) will redirect with an HTTP status 301 (Moved Permanently) to the same URL with a slash appended. | ||||
|  | ||||
| ## Examples | ||||
|  | ||||
|   / -> internal redirect -> /index.html | ||||
|   /foo/bar/ -> internal redirect -> /foo/bar/index.html | ||||
|   /foo -> external redirect (301) -> /foo/ | ||||
|   /foo.html -> no redirect | ||||
|   /foo/bar.html -> no redirect | ||||
|   /foo/index.html -> external redirect (301) -> /foo/ | ||||
|  | ||||
| ## Notes | ||||
|  | ||||
| This URL scheme is somewhat opinionated. It tries to balance SEO requirements with server-side tooling. (E.g. S3 tooling tries to infer the content-type from the file extension.) | ||||
|  | ||||
| It allows you to have very nice outward facing URLs like "/cooltopic", that internally use a file with a correct extension: "cooltopic/index.html". To have content other than index.html in a folder, you need to expose the file extension: "/cooltopic/somecontent.html" | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
| 1. Create a function called "LATE-standard-redirects-for-cloudfront" in N. Virginia (us-east-1) | ||||
| 2. Run "npm run deploy" | ||||
|  | ||||
| This function assumes that your CloudFront distribution handles the URL "/" directly by having the property "Default Root Object" | ||||
| set to "index.html".  | ||||
|  | ||||
| TODO: IAM, SAM | ||||
		Reference in New Issue
	
	Block a user