Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Map new domain to cPanel sub domain?

Discussion in 'Bind/DNS/Nameserver' started by Tarounen, May 19, 2018.

Tags:
  1. Tarounen

    Tarounen Registered

    Joined:
    May 19, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,786
    Likes Received:
    82
    Trophy Points:
    78
    Location:
    India
    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 ^(.*) http://domain.net/website2/$1 [P]
    ------------------- -------------------
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Tarounen

    Tarounen Registered

    Joined:
    May 19, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Mauritius
    cPanel Access Level:
    Root Administrator
    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
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,672
    Likes Received:
    1,788
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice