Can I point a sub domain of one site to the root of another on same server / IP

12,074

Solution 1

If your cPanel main domain is mycompany.com just create an addon domain myclient.com

Create myclient.com
Automatically a subdomain myclient.mycompany.com that points to the webroot of myclient.com is created.
Just check it on Subdomains page.


enter image description here

If your cpanel main domain is something else, go to the Addon Domains page and create myclient.com. Note the Document Root automatically generated (most probably /public_html/myclient.com) here or type your own Document Root and copy it.

and then create a subdomain myclient.mycompany.com by pasting myclient.com's Document Root in the Document Root field.

myclient.com will be accessible through myclient.mycompany.com

Hope that helps...

Peace be upon you...

Solution 2

I went there and did it! But not like I told earlier.

On WHM go to park a domain. Select the domain where you want to park another one.

On the right type the new subdomain. I mean, select "myclient.com" and type myclient.mycompany.com on the right.

Update or save. Wait just a few seconds and try it!

But you must not create the subdomain anywhere else.


The other way is just create an "A" entry on DNS of mycompany.com like this: myclient A "IP where myclient.com is". But it just works if you have an IP to myclient.com and no sharing! (shared ip doesn't work doing this...)

Solution 3

For PLESK:

  1. add a new file named: vhost.conf in subdomain's conf folder with just one line: DocumentRoot [your new path]

Your new path may be: - for new domain root: /var/www/vhosts/(new domain)/httpdocs/ - for new domain subdomain: /var/www/vhosts/(new domain)/subdomains/(subdomain)/httpdocs/

  1. execute as root /usr/local/psa/admin/bin/websrvmng -a
  2. restart apache from plesk or execute: service httpd restart
Share:
12,074
Mere Development
Author by

Mere Development

I'm a freelance php'ish Wordpress'ish developer...

Updated on June 04, 2022

Comments

  • Mere Development
    Mere Development almost 2 years

    I have this (pseudo) domain setup, and hope to do any configuration via cPanel and/or WHM.

    myclient.com - this hosts a development site and there is no public DNS for it yet (by choice) mycompany.com - this is my company's domain name and it's publicly accessible. myclient.mycompany.com - this is the domain I want to use to preview the myclient website during development.

    Edit for clarity: All 3 are on the same server and same IP.

    So, is it possible to point that subdomain (myclient.mycompany.com) to the webroot of myclient.com using cPanel or WHM?

    I've looked at addon domains, redirects and parked domains but each of them can only relate to own account, or cannot be used with another domain if it's managed by the same server.

    Any idea? :/

  • Mere Development
    Mere Development about 12 years
    Hi Ahmed, thanks for responding. I tried that earlier and get this response: "Error from park wrapper: myclient.com is already configured. Sorry, that domain is already setup (remove it from httpd.conf)" . myclient.com is already setup on that server, so I don't think what I want to do is possible via WHM/cPanel now. Any more thoughts?
  • Tabrez Ahmed
    Tabrez Ahmed about 12 years
    Also check for any cname and a or aaa records that are as myclient.com. If they exist remove them and then try again...