Map a Domain to Subdomain both on same server

Operating System & Version
CentOS 7
cPanel & WHM Version
Latest

webiscore

Registered
Jul 23, 2020
2
0
1
cPanel
cPanel Access Level
Root Administrator
I'm developing a website for a client which isn't wordpress but an MVC architecture. His account/domain and my account/domain are both hosted on the same server and IP address.
I don't wanna share the code however I wanna map hisdomain.com to subdomain.mydomain.com while he keeps accessing his on cPanel to create email and install the SSL.
While anyway tries to access subdomain.mydomain.com it will show hisdomain.com
The option is easy to be achieved via Wordpress however any other frameworks like Opencart, Laravel, CodeIgniter, etc. I couldn't find any way to achieve that.
  • I entered a CNAME record pointing subdomain.mydomain.com to hisdomain.com
  • Then I removed www A records from DNS at hisdomain.com and changed it to CNAME pointing hisdomain.com to subdomain.mydomain.com
Both returns "Index of /" when I try accessing hisdomain.com with www and without www.
I googled and searched a lot couldn't find the suitable answer for that. Any suggestion please!
How to Map/Point a Domain to Subdomain both on same server sharing same IP?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,293
1,279
313
Houston
If you want to map hisdomain.com to subdomain.mydomain.com the easiest way to do this would be to create an Alias for hisdomain.com on the server where subdomain.mydomain.com is hosted - this would require creating an A record for hisdomain.com where DNS for it is hosted.

IF you wanted to do this using a CNAME you would need to ONLY point hisdomain.com to subdomain.mydomain.com where DNS for hisdomain.com is managed. You would not make ANY changes to subdomain.mydomain.com.
 

webiscore

Registered
Jul 23, 2020
2
0
1
cPanel
cPanel Access Level
Root Administrator
The first option will not allow me to share a dedicated cPanel account to the client while both subdomain and hisdomain are hosted on my account. I need to have 2 seperate accounts on the same server.

The second option didn't do the trick I set the CNAME for hisdomain to subdomain.mydomain.com but it returns the main domain "mydomain.com" instead of "subdomain.mydomain.com". Also if somebody accesses the subdomain.mydomain.com it won't redirect it to hisdomain.com