How to Reverse proxy based on subdirectories instead of subdomains?

What is the name of the domain?

null

What is the issue you’re encountering

How to Reverse proxy based on subdirectories instead of subdomains?

What steps have you taken to resolve the issue?

Reverse proxy based on subdirectories instead of subdomains

Hello, I would be very grateful if someone could reply, I have a problem and I’m not sure how to do it.
Our company have the following 6 websites, using subdirectories instead of subdomains.
Each website uses WordPress (with WooCommerce functionality), and the server configuration is Apache.

xxxxxxx. com US B2C site, assuming server IP is: 1.1.1.1
xxxxxxx. com/wholesale US B2B site, assuming server IP is: 2.2.2.2

xxxxxxx. com/kr South Korea B2C site, assuming server IP is: 3.3.3.3
xxxxxxx. com/kr/wholesale South Korea B2B site, assuming server IP is: 4.4.4.4

xxxxxxx. com/jp Japan B2C site, assuming server IP is: 5.5.5.5
xxxxxxx. com/jp/wholesale Japan B2B site, assuming server IP is: 6.6.6.6

To be able to access websites on different servers by accessing different paths and ensure that each website functions correctly, and the user login and order placement functions are not affected,What features of Cloudflare should I use to achieve this? Cloudflare Workers?

Or, on a more advanced note, can people from different geographic locations visiting xxxx. com be directed to the corresponding country?

Thank you!

What feature, service or problem is this related to?

I don’t know

Welcome to the Cloudflare Community. :logodrop:

It won’t work at the DNS level since the path is not part of the query that translates a hostname into an IP address. That means that example.com/kr will return the same IP as example.com/jp. You may be able to write some code that runs in Cloudflare Workers that can direct requests to different origins based on the URI path.

Do you currently have a system in place that is directing visitors to different origin severs based on the URI path? If so, how have you currently implemented that?

You certainly do have options with directing traffic based on geographical origin. Can you tell us more about how your current setup works?

Currently, we have not set anything up, and I am not sure if Cloudflare Workers can achieve this,If Cloudflare can do it, I will further investigate how to write the relevant code. I asked AI, like Grok3 and Gemini 2.5 Pro, and AI told me that it can be done through Cloudflare Workers, but I’m not sure, so I’m seeking help.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.