Redirect main domain to new hosting IP while leaving existing /xxx on current URL/IP

Hello all,

I have the scenario of the client has domain dot com/administration with a custom application at that URL they use.
We have built them a new website which we are hosting, but we cannot host their /administration application.

I am wanting to some how use page rules to forward all traffic for domain dot com to our cpanel IP which has an account set up for domain, I am assuming I will need to do this via the IP address of our cpanel/whm?

While doing this when they go to domain com/administration, I need that URL to continue on back to its original location where that application is hosted.

I have directed domain.com to Cloudflare, but getting the page rule to do this I am a bit stuck.

Using the most basic tools Cloudflare provides:

To get all their domain.com traffic to your cpanel you just need to use dns - i.e. domain.com A record pointing to your IP address (or you can even use a CNAME here, Cloudflare will flatten it and return as an A record).

To override this for domain.com/administration you need to assign a different hostname to their old site, such as legacy.domain.com and have the DNS for this pointing to their existing hosting, then set up a page rule such that domain.com/administration redirects to https://legacy.domain.com/administration.

One could expand this so that the page rule is domain.com/administration* redirects to https://legacy.domain.com/administration$1 where the $1 will contain whatever is in the * of the landing page - this would catch any bookmarks users may have to ‘deeper’ URLs in the admin application.

Better, but beyond the remit of a simple answer here would be to use a Cloudflare Worker which passes all domain.com/* requests to your backend other than those to /application paths which are passed to the legacy backend dynamically without any such re-write. A little bit more involved and not sometihng I’d just set up for a client off the bat as although it’s probably ‘the right way’ to do it, it might be a bit confusing for them to manage if you hand the whole thing over to them after your work is done.

This topic was automatically closed after 14 days. New replies are no longer allowed.