cancel
Showing results for 
Search instead for 
Did you mean: 

Map new domain name to Cpanel subdomain

Hello, 

i have a deluxe web hosting plan hosting two website. let say the main domain name is A.

so i have A/website1 and A/website2. 


Now i purchase another domain B and want to point B to A/website2. 

I tried to configure the DNS mapping and setup Addon Domain on Cpanel. 

 

The redirection seems to be working but whenever i write B on a browser it rewrite to A/website2. 

 

Is there a way to prevent this? 

 

Thanks.

 

5 REPLIES 5
Super User I Super User I
Super User I

Re: Map new domain name to Cpanel subdomain

Seems like you're trying to get this done the hard way with the DNS mapping @tarounen? I assume that your directory structure is root for domaina.com and root/website2 for domaina.com/website2 or website2.domaina.com?

 

I'd just try Add addon domains to host multiple websites (cPanel) that way you could just point your domainb.com to hosting root/website2 I hope that helps? Come back and let us know. 

 

...turns out that my two cents is worth less or more depending on the current exchange rate.

roy darling *my posts seem a lot shorter in my head

Re: Map new domain name to Cpanel subdomain

That's what i did. i configure DNS mapping + addon domain.

 

i managed to fix the redirection using:

 

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*) http://domain.net/website2/$1 [P]

However  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?

Super User I Super User I
Super User I

Re: Map new domain name to Cpanel subdomain

Maybe I'm looking at this too simply @tarounen? Your first domain shouldn't even need a rewrite, it should just be pointed to your hosting root and that should be your website1. When you go to that domain you should just see domaina.com in your address bar. When setting up your addon domain the root becomes whatever directory you point it to. I say get rid of the rewrite stuff unless you are trying to do a secure redirect. Does that make sense? 

 

...turns out that my two cents is worth less or more depending on the current exchange rate.

roy darling *my posts seem a lot shorter in my head

Re: Map new domain name to Cpanel subdomain

okay. i did what you suggested, i ditched the redirect rules. i put the index file of website1 the root directory of the hosting itself and updated the redirect rules for website2.

 

one thing i wanted to be sure? does the DNS mapping plays some role after i did the addon domain? 

also if i had to apply an SSL on website2 sould i be apply it to domainb.com or on the hosting root having domaina.com as primay name?

Thanks

 

 

Super User I Super User I
Super User I

Re: Map new domain name to Cpanel subdomain

Since your root is domaina.com you

 

Since you have domaina.com pointed to the root you can access domaina.com/website2 or domainb.com When you're installing a SSL you need to set it up directly on domainb.com

 

You could do DNS mapping of you want but it gets complex. You can just use the addon domain for simplicity.

 

If you are installing a SSL check out Redirect HTTP to HTTPS automatically. I hope that helps?

 

...turns out that my two cents is worth less or more depending on the current exchange rate.

roy darling *my posts seem a lot shorter in my head