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

126
Views
Mi respuesta del trabajador de Cloudflare de otro sitio web no funciona

Tengo un sitio web, por ejemplo, Example.com en Blogger y un subdominio blog.example.com

Quiero hacerlo como example.com/blog

Sor, ejecuto un trabajador de cloudflare para este Sor que funciona así

Y otra codificación para que cada url en el sitio de origen cambiara a este nuevo d url example.com/blog pero no funciona, ¿alguien puede ayudarme?

el codigo es

 const OLD_URL = "https://blog.example.com" const NEW_URL = "https://example.com/blog" async function handleRequest(req) { const res = await fetch(req) return rewriter.transform(res) } class AttributeRewriter { constructor(attributeName) { this.attributeName = attributeName } element(element) { const attribute = element.getAttribute(this.attributeName) if (attribute) { element.setAttribute( this.attributeName, attribute.replace(OLD_URL, NEW_URL) ) } } } const rewriter = new HTMLRewriter() .on("a", new AttributeRewriter("href")) .on("img", new AttributeRewriter("src")) .on("link", new AttributeRewriter("href")) .on("meta", new AttributeRewriter("content")) addEventListener("fetch", event => { let url = event.request.url.split("/blog")[1] event.respondWith(handleRequest(OLD_URL+url) .catch(err => new Response(err.toString(),{status:500}))) })
about 4 years ago · Juan Pablo Isaza
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!