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
EXPERTO
preguntada hace 6 meses13 visualizaciones
1 Respuesta
0

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

https://example.com/test/#

那么这将被发送到Lambda:

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

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

profile picture
EXPERTO
respondido hace 6 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas