How to point a sub domain of one account to sub domain of another account

RussellDavies

Member
Oct 26, 2022
6
0
1
united kingdom
cPanel Access Level
Root Administrator
I'm sure this has been covered before on the forum so apologies if this is the case. I did scan through the posts but couldn't see an answer to my problem.

I'm very new to WHM and Cpanel but have been asked to sort out this issue.

We have a website/account running under a domain (e.g. www.primarydomain.co.uk).

We've set up a new site using a dev domain using a sub domain (e.g. newsite.devdomain.co.uk).

Now we want to point a sub domain of the primary site to the new site (e.g. newsite.primarydomain.co.uk should show the site at newsite.devdomain.co.uk).

I've tried everything and scoured the web for answers but can't seem to work out how to do this.

Can anyone help?
 
Last edited by a moderator:

RussellDavies

Member
Oct 26, 2022
6
0
1
united kingdom
cPanel Access Level
Root Administrator
Hey there! The simplest way would be to use a redirect from the primarydomain.co.uk account. You can do this from the cPanel >> Redirects page.

Try that and let us know how it goes!
Thanks for replying. If i use a redirect won't that just show the site under the current domain though? What I wanted was for the url to be newsite.primarydomain.co.uk rather than show the development url (i.e. newsite.devdomain.co.uk).
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,554
2,609
363
cPanel Access Level
Root Administrator
Thanks for the additional details. Yes, the redirect would change the URL.

The easiest option may be to create an Alias domain - this just sets up Apache with multiple domains pointed to the same document root.

If that doesn't work well, you may need a custom .htaccess rule to handle the rewrite and redirect. I've had good luck with this in the past for similar situations:

Code:
RewriteCond %{HTTP_HOST} ^(www\.)?original-domain\.com$ [NC]
RewriteRule ^ http://www.destination-domain.com%{REQUEST_URI} [L,NE,P]
but you may need to tweak that as necessary for your specific situation.
 
  • Like
Reactions: RussellDavies

RussellDavies

Member
Oct 26, 2022
6
0
1
united kingdom
cPanel Access Level
Root Administrator
Thanks for the additional details. Yes, the redirect would change the URL.

The easiest option may be to create an Alias domain - this just sets up Apache with multiple domains pointed to the same document root.

If that doesn't work well, you may need a custom .htaccess rule to handle the rewrite and redirect. I've had good luck with this in the past for similar situations:

Code:
RewriteCond %{HTTP_HOST} ^(www\.)?original-domain\.com$ [NC]
RewriteRule ^ http://www.destination-domain.com%{REQUEST_URI} [L,NE,P]
but you may need to tweak that as necessary for your specific situation.
I'll give this a go. Thanks
 

RussellDavies

Member
Oct 26, 2022
6
0
1
united kingdom
cPanel Access Level
Root Administrator
Thanks for the additional details. Yes, the redirect would change the URL.

The easiest option may be to create an Alias domain - this just sets up Apache with multiple domains pointed to the same document root.

If that doesn't work well, you may need a custom .htaccess rule to handle the rewrite and redirect. I've had good luck with this in the past for similar situations:

Code:
RewriteCond %{HTTP_HOST} ^(www\.)?original-domain\.com$ [NC]
RewriteRule ^ http://www.destination-domain.com%{REQUEST_URI} [L,NE,P]
but you may need to tweak that as necessary for your specific situation.
Ok, so i've used the Parked domain option but it's just forwarding the user to the dev url and not displaying the site under the url I wanted. Looks like this is causing an issue with our network at work because it's essentially a redirect which is being blocked by our network policy.

Isn't there a way to set the DNS of the destination domain to use a CNAME or A record to point to the site?
 
Last edited:

rbairwell

Well-Known Member
May 28, 2022
117
49
28
Mansfield, Nottingham, UK
cPanel Access Level
Root Administrator
Ok, so i've used the Parked domain option but it's just forwarding the user to the dev url and not displaying the site under the url I wanted.
This sounds like a .htaccess style issue - where it is detecting which domain name is being accessed and then redirecting to the "correct" one (such as adding www. etc). It could also be some code in the site which is detecting the hostname. The fact the parked domain is working and then it is redirecting you to the dev url indicates to me that "cPanel wise" everything is working correctly and that it is code within the site itself which is doing the redirect.