Lambda@Edge Redirect when URL ends with #

0

My customer hosts a static website on S3, fronted by CloudFront. They rolled out a version that leads to an invalid URL: www.example.com/test1/#

They would like to redirect all test1/# requests to test1/index.html

I thought of two options that failed:

A. Lambda@Edge redirect: Failed, because the parameter "#" is invalid when defining a behavior:

com.amazonaws.services.cloudfront.model.InvalidArgumentException: The parameter globPattern can only contain these characters: [a-zA-Z0-9_-.*$/~"'&@:?+\]. (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidArgument; Request ID: d0; Proxy: null)

B. Uploading a file called "#" and edit its metadata to redirect but it doesn't work. CloudFront allows me to download the file.

Nir_Sh
질문됨 3년 전818회 조회
1개 답변
0
수락된 답변

The problem is that the "#" is a directive to the browser, and does not get sent to the server, whether it is Lambda@Edge or any other server. For example if I request:

https://example.com/test/#

Then this gets sent to the Lambda:

"method": "GET",
"querystring": "",
"uri": "/test/"

If there were text after the #, then you could access it in client-side JS via location.hash

profile pictureAWS
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠