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}))) })