The basic idea is simple:
My server hosts two domains - alice.com
and bob.com
. For the most part they are different, unrelated websites, but there is one URL that used to be at alice.com
that now needs to go under bob.com
. In other words, when a request comes in to http://alice.com/webhook.php
, I want the request to land at http://bob.com/webhook.php
.
So far so simple, until you take the wrinkles into account:
- This is a webhook that an external 3rd party server calls. I cannot get the 3rd party to change the URL and I don't know if they are capable of following HTTP redirects, so I assume the worst. Thus, I don't want a HTTP redirect - I simply want Apache to handle this internally. (For the curious - this is PayPal's IPN callback).
- I don't own or fully control the server - it's managed by the hosting company. In particular, I don't have root access and cannot edit Apache's full configuration. I can only use
.htaccess
files to achieve this (or, in the worst case, I could also just make a bit of PHP code that proxies the request...)- However I can ask the hosting company to add Apache modules and they will do it, if it's a reasonable request.
- The way it's set up, each website runs under a different user account (via PHP-FPM), so I can't just use PHP's
include()
. - The domains
alice.com
andbob.com
are run through Cloudflare. My server responds to these domains, but the DNS records actually point them to Cloudflare. So while I can set upmod_proxy
to simply issue a background request to the other domain, this will make an unnecessary loop through Cloudflare and introduces an extra point of failure. It's an option, but I'd prefer to avoid this. In fact, proxying of any kind seems like an unnecessary step, since both websites run under the same Apache. I just need to rewrite theHost
...
Can this be achieved somehow?