Map new domain to cPanel sub domain?

Tarounen

Registered
May 19, 2018
2
0
1
Mauritius
cPanel Access Level
Root Administrator
I have a cpanel account, with primary domain domain.net, hosting 2 website (having 2 directories website1 and website2). i created the subdomain and redirections.

website1.domain.net -> domain.net/website1
website2.domain.net -> domain.net/website2

I purchase a seperate domain: domain.com and tried to map it on a subdomain mentioned previously websbite2.domain.net.

I configured the DNS mapping for domain.com and created an addondomain in cpanel. The redirection works fine.

My problem is that whenever I type domain.com in a browser it changes the url to domain.net/website2.

Is there a way to do the redirection but keeping the domain unchanged?

Thanks
 

24x7server

Well-Known Member
Apr 17, 2013
1,911
99
78
India
cPanel Access Level
Root Administrator
Twitter
Hi,
My problem is that whenever I type domain.com in a browser it changes the url to domain.net/website2.
You may have to do URL masking also. Try the below code in the .htaccess..
Code:
------------------- -------------------
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*) http://domain.net/website2/$1 [P]
------------------- -------------------
 

Tarounen

Registered
May 19, 2018
2
0
1
Mauritius
cPanel Access Level
Root Administrator
Hi,

You may have to do URL masking also. Try the below code in the .htaccess..
Code:
------------------- -------------------
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*) [URL]http://domain.net/website2/$1[/URL] [P]
------------------- -------------------
Thank you for replying. i did the change however it doesn't seem to be working as expected.

Note that in the .htaccess of the root dir, i inserted a rule to redirect any request to domain.net/website1

RewriteEngine On
RedirectMatch ^/$ /website1
ErrorDocument 404 domain.net

After the update, when i go to domain.com it simply redirects to -> domain.com/website1.

can this be fixed?
Thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
i created the subdomain and redirections.

website1.domain.net -> domain.net/website1
website2.domain.net -> domain.net/website2
Hello @Tarounen,

I recommend disabling the existing redirects, and instead configuring the document roots of those subdomains to the path you'd like them to load the contents from. You can adjust the document root value under Modify a Subdomain in cPanel >> Subdomains.

Thank you.