I've been handed a website using cloudflare workers to redirect a wordpress blog hosted in a subdomain to a subdirectory - for the most part it's a copypaste from this cloudflare article plus an if-check to redirect to the right locale - in other words:
- blog.companyname.com/en is masked as www.companyname.com/blog
- blog.companyname.com/es is masked as www.companyname.es/blog
- blog.companyname.com/de is masked as www.companyname.de/blog
etc.
Of course they found out that crawlers and users could still access the original blog.companyname.com address, and asked me if I could somehow stop this host being directly accessible without causing issues for regular traffic. Couldn't come up with a working solution using .htaccess trying to redirect everything excluding the Cloudflare IP block, and I'm wondering if i'm using the wrong approach (I'm a designer and wordpress developer by trade, definitely not a sysop/devop).
The blog is hosted on a managed solution using apache 2.4.6. Any suggestion is greatly appreciated.