# Mapping secondary domain to subdirectory on existing host.



## Walter Odim (Jun 29, 2008)

I've been scratching my head for a while now on how to achieve this. I currently have two domains, one of which has a hosting package. I've been trying to figure out whether it's possible to map the secondary domain (without the hosting package) to a directory in my other site, and have it function as it would do normally. (websiteb.com = main page, websiteb.com/content = contents, etc) 

I have access to DNS and nameservers, but having trouble figuring out whether what I'm trying to do is even possible. I have an option for a framed redirect, but that isn't quite what I was trying to achieve. (I'm a bit of a webhost newbie, so not even overly clear on what it is either!)

I've heard that some people have achieved something similar with .htaccess, but I'm a bit confused! Currently the websiteb leads to a 'PAGE IS RESERVED' message. 

What should I do? (both domains and hosting are with the same company. It's not an overly popular host, but seems to fulfill my casual needs.)

Any ideas?


----------



## wmorri (May 29, 2008)

Hi,

I would recommend that for this matter you message your hosting company. I am sure that they have a quick and easy solution, and may even do it for you.


----------



## MartyF81 (Jan 23, 2013)

I did this once and it was a huge hassle and confusing set up between my host and domain registrar. You will have to set specific specific C-Name or A-Name Records (I cannot remember which, and my brain kind of hurts this afternoon)

But as wmorri suggested either way you need to talk to your Domain provider and Host.

The setup principles are universal, but each host/domain registrar will have specific settings and control panels. Since the Domain Registrar and Host are the same company for you.... then it should be easy for them to do for you. They also may not allow it, or charge a fee to do it. I have had that happen too.


----------



## Fjandr (Sep 26, 2012)

It's fairly easy to do this, but your host has to support mapping domains to subdirectories.

As above, you need to contact your host's support if you can't find the options in the control panel.


----------



## Walter Odim (Jun 29, 2008)

Thanks for the replies. I thought I might have to resort to contacting support - this is where the cheap reseller hosts really shine banghead, I guess I'll find out if it's possible. I've tried a framed redirect, but it's ugly as sin and breaks a lot of things (if I click internal links, I'm left with frames-within-frames, and a completely static address. Complete opposite of what I wanted! Eek!).

I'll wait on an answer, and let you guys know. If anyone else has any ideas, I'd love to hear them.


----------



## Fjandr (Sep 26, 2012)

If you don't get a decent answer from your host's support team, let us know what control panel the host uses. May be able to get you set based on the capabilities of the control panel, depending on what it is. Cpanel is the most common control panel installed on shared web hosts, but there are others out there.


----------



## Walter Odim (Jun 29, 2008)

Hi there. I contacted support, and he recommended I use a redirect as anything else is "too fiddly". I wasn't happy with that response, so I've been looking at other hosts, in case I cannot get this configured correctly. 

I'll having trouble finding what panel my host uses, I believe the web-hosting is cpanel (extendcp.co.uk/ is the address that appears in my bar when accessing it), although when I try to configure my domain (redirections, DNS, and so on) it's achieved via managethisdomain.com.


----------



## wmorri (May 29, 2008)

It appears that you are using the Extend Control Panel, I can't find much on it at first look, but I will do a little more searching and see what I find.


----------



## Fjandr (Sep 26, 2012)

If it's CPanel, under the Domain section is Add-on Domains. You can use that to set the root domain directory to any subdirectory.


----------



## Walter Odim (Jun 29, 2008)

Hi. I think wmorri was correct, it seems to be Extend Control Panel, and Manage My Domain. I'm only given an option to create subdomains, not much else. Decided to cut the hassle, and move to a more reliable host. The support given by the company has been useless, and seem about as clueless as me! 

Thanks.


----------



## Fjandr (Sep 26, 2012)

That's pretty common in the shared hosting industry. Reliable, knowledgeable, and helpful hosts are fairly rare.


----------



## SteveThePirate (Jan 12, 2012)

Hi,

Just shoving my tuppence out there. I work for a hosting company here in the UK and the guys are right, most of the shared hosting companies can be a bit dodgy with support if they don't know what they are talking about. You were right in your first post though, I've done it once i think with a .htaccess. You obviously have to have linux hosting for this but if you add the following lines to a .htaccess file and enter the domain details and folder path as necessary (this is an example i'm not 100% if it works properly);


```
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?main\-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/sub\-folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /sub-folder/$1
RewriteCond %{HTTP_HOST} ^(www.)?main\-domain.com$ [NC]
RewriteRule ^(/)?$ sub-folder/index.php [L]
```


But again, the hosting provider needs to support domain mapping.


Steve


----------

