Wordpress Subdomain to Subdirectory Reverse Proxy Worker


I currently have a wordpress blog that is hosted on a Debian 12 server using apache. The url of the blog is in the format of https://blog.domain.co.uk

I also have a website which runs in node.js hosted on another server with the url of https://www.domain.co.uk

I cannot install wordpress on the main domain server as that server does not run php.

I would like to use a Cloudflare worker to reverse proxy all requests for http://www.domain.co.uk/blog to https://blog.domain.co.uk

I would also like to stop people being able to access https://blog.domain.co.uk directly.

Effectively this would mean that my blog url now appears to be https://www.domain.co.uk/blog

I have tried to do this using the nginx reverse proxy on my node.js server but it has got very complicated. I have also tried to implement the solution shown here but it also does not work https://blog.cloudflare.com/subdomains-vs-subdirectories-improved-seo-part-2/

I have also tried https://www.sammyseo.com/subdomain-to-subfolder-the-simple-cloudflare-reverse-proxy/ and it to doesn’t work correctly as it stops me being able to create new posts in wordpress and also stops plugins like Yoast from working altogether.

I would really appreciate it if anyone could offer a solution as this is seemingly very difficult to achieve.


Hey! We have recently published a guide on our blog that explains the process of hosting your WordPress blog on a subdirectory using Cloudflare workers.

Check it out here: https://shapo.io/blog/wordpress-blog-on-a-subdirectory-with-cloudflare/