Thanks for your suggestion. Here’s my worker code:
addEventListener(“fetch”, (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
// Get the URL of the incoming request
const url = new URL(request.url);
// Check if the path starts with “/blog”
if (url.pathname.startsWith(“/blog”)) {
// Redirect to the blog subdomain
const redirectUrl = `https://blog.domain.com${url.pathname.replace(“/blog”, “”)}`;
return Response.redirect(redirectUrl, 301); // Use 301 for permanent redirect
}
// If the path doesn’t match “/blog”, proceed with the normal request
return fetch(request);
}
And here’s the worker route condition:
*domain.com/blog*
However, I still encounter the bubble 404 error page.