Lambda@Edge如何将以#结尾的URL进行重定向?

0

【以下的问题经过翻译处理】 我的客户在S3上托管了一个静态网站,由CloudFront提供前端支持。他们推出了一个版本,导致一个无效的URL:<www.example.com/test1/#>。

他们希望将所有test1 /#请求重定向到test1 / index.html。

我尝试两种方式都失败了:

A. Lambda@Edge 重定向:失败,因为定义行为时参数“#”无效:

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.上传名为“#”的文件并编辑其元数据进行重定向,但不起作用。 CloudFront允许我下载该文件。

profile picture
전문가
질문됨 6달 전13회 조회
1개 답변
0

【以下的回答经过翻译处理】 问题在于“#”是浏览器的指令,不会发送到服务器,无论是Lambda @ Edge还是任何其他服务器。例如,如果我请求:

https://example.com/test/#

那么这将被发送到Lambda:

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

如果#后面有文本,那么您可以通过“location.hash”在客户端JS中访问它。

profile picture
전문가
답변함 6달 전

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

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

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

관련 콘텐츠