Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
Cómo eliminar la extensión .html con AWS Lambda y Cloudfront
  1. Tengo el código fuente de mi sitio web almacenado en AWS S3 y estoy usando AWS Cloudfront para entregar mi contenido.
  2. Quiero usar AWS Lamda@Edge para eliminar la extensión .html de todos los enlaces web que se ofrecen a través de Cloudfront.
  3. Mi salida requerida debería ser www.example.com/foo en lugar de www.example.com/foo.html o example.com/foo1 en lugar de example.com/foo1.html.

Ayúdenme a implementar esto ya que no puedo encontrar una solución clara para usar. He referido el punto 3 mencionado en este artículo: https://forums.aws.amazon.com/thread.jspa?messageID=796961&tstart=0 . Pero no está claro lo que tengo que hacer.

PFB el código lambda, ¿cómo puedo modificarlo-

 const config = { suffix: '.html', appendToDirs: 'index.html', removeTrailingSlash: false, }; const regexSuffixless = /\/[^/.]+$/; // eg "/some/page" but not "/", "/some/" or "/some.jpg" const regexTrailingSlash = /.+\/$/; // eg "/some/" or "/some/page/" but not root "/" exports.handler = function handler(event, context, callback) { const { request } = event.Records[0].cf; const { uri } = request; const { suffix, appendToDirs, removeTrailingSlash } = config; // Append ".html" to origin request if (suffix && uri.match(regexSuffixless)) { request.uri = uri + suffix; callback(null, request); return; } // Append "index.html" to origin request if (appendToDirs && uri.match(regexTrailingSlash)) { request.uri = uri + appendToDirs; callback(null, request); return; } // Redirect (301) non-root requests ending in "/" to URI without trailing slash if (removeTrailingSlash && uri.match(/.+\/$/)) { const response = { // body: '', // bodyEncoding: 'text', headers: { 'location': [{ key: 'Location', value: uri.slice(0, -1) }] }, status: '301', statusDescription: 'Moved Permanently' }; callback(null, response); return; } // If nothing matches, return request unchanged callback(null, request); };

Ayúdenme a eliminar la extensión .html de mi sitio web y qué código actualizado necesito pegar en mi AWS Lambda ¡Gracias de antemano!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!