I have a service service[dot]com. The service allows, for example, to create a landing page, which after creation is available at app.service[dot]com/<long_path_here_with_symbols>.
Our user needs the created page to open not at this long our address, but at his branded one, for example, landing.client[dot]com. There can be as many clients as you like: landing.client1[dot]com, landing.client2[dot]com, landing.client3[dot]com, and so on, so the solution must be scalable. It is important that after switching to landing.client[dot]com, there should not be a redirect to app.service[dot]com/<long_path_here_with_symbols>, and landing.client[dot]com should remain in the browser address bar, but the app.service[dot]com/<long_path_here_with_symbols> page should open.
As far as I was able to find out, this is done somehow through aliases, not redirects. The option of embedding an iframe to the client on the landing.client[dot]com page with our landing is not considered. I am sure that the problem can be somehow solved by editing the DNS on the client and with certain settings on the service[dot]com/app.service[dot]com side.
I studied many different sources, but I want to note one here - https://stackoverflow.com/a/17753713 - I registered CNAME cname.service[dot]com at landing.client[dot]com (now the call goes to the ip of our server when clicking on landing.client[dot]com, I also realized that I need a VPS, not a regular shared-hosting). I understand that editing the CNAME does not open another site, but simply gives the ip to access.
From various articles on the Internet, I realized that when landing.client[dot]com opens, then there is a call to the ip on which cname.service[dot]com lies, however, then the target server must understand what they want from it (namely, you need to open, for example, app.service[dot]com/<long_path_here_with_symbols>).
I saw that it seems that aliases are written in the Apache config, but even if so, I don’t understand how adding these aliases can be made dynamic.
The description of the question turned out to be chaotic, but I hope that this information is enough to understand what I'm trying to do.
Our service is written in PHP.
UPD 1: Following the advice of @arkascha I decided to simplify the task a little. So, to solve my problem I did 2 steps:
I created test service subdomain cname.service.com, then I created landing.client.com and added CNAME cname.service.com. IN landing.client.com. Now if I go to landing.client.com I see that IP for landing.client.com is the same with cname.service.com in my browser console.
In cname.service.com site root I created .htaccess file with these lines:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteRule ^$ ./index.php?landing_id=%1 [L]
Now I expected, that if I go to landing.client.com, browser will open cname.service.com and I will get GET-parameter landing_id="landing.client.com"
, but it doesn't. I keep trying to solve the problem on shared-hosting, not vps.
UPD 2:
If I go to landing.client.com
manually the browser’s network console shows:
Status: 200
IP: 89.255.251.130:80
URL in browser’s address bar doesn’t change.
In this case access.log
and error.log
are empty on both sites (landing.client.com
and cname.service.com
)
If I go to cname.service.com
manually the browser’s network console shows:
Status: 200
IP: 89.255.251.130:80
Of course, it adds new line in access.log
on cname.service.com
("GET / HTTP/1.1" 200)
When I request landing.client.com
, index.php script
of cname.service.com doesn’t get called.
I keep trying to solve the problem on shared-hosting, not vps.