Currently, I have a blog hosted on the Blogspot platform, and I have many 404 URLs that I want to redirect to new URLs.
I am using Cloudflare Worker to do this, and I have already tested it via the test menu on the Cloudflare Worker, and the previously 404 URLs have been successfully redirected to the new URLs with a 301 status.
However, when I access it via a web browser, the page still shows a 404 status, while using curl, the URL returns a status of 200 (blank).
Yes, the code in the playground works as expected. However, on the actual page with errors, the one I tested in the playground didn’t produce an HTTP status header of 301; the page still returned a 404 error. When I tested it using curl, the result was 200 OK, just as I mentioned at the beginning of the thread.
In the worker summary, I noticed that there were incoming requests registered by the Worker script.
Yup … as simple as I mentioned earlier, the goal is to redirect 404 URLs to a new page.
The steps I took are as follows…
I created a Cloudflare worker with the above code, and my route is set to *.budidayatani.com/*
It seems like the code in the Cloudflare worker is running as it should (both the code I initially pasted and the code you provided) when we test it in the worker playground.
The issue arises in the real-world implementation… the URL that was previously a 404 should now have a 301 status, but as I mentioned above, the URL is still a 404 when accessed through a web browser and returns a 200 OK when using curl.
using online url checker : https://redirect.li/http/?url=https%3A%2F%2Fwww.budidayatani.com%2Fmanfaat-burung-merpati-sebagai-alat.html
its status also returning 200 OK , im expecting to have status 301 and redirected to new url https://www.budidayatani.com//2019/06/manfaat-burung-merpati-sebagai-alat.html
Yes, bloggers do have a redirect feature, but that’s the problem. This feature doesn’t work as I expected, especially with parameters. It generates multiple unnecessary redirects or redirects to URLs I didn’t expect. That’s why I have the idea to use Cloudflare workers.
What confuses me is why Cloudflare workers produce different status headers, as I mentioned earlier.