Forum Moderators: phranque

Message Too Old, No Replies

Multiple Websites, One Hosting Plan

How do I implement?

         

MrFishGuy

3:57 pm on Oct 3, 2008 (gmt 0)

10+ Year Member



My hosting plans, according to my hosting company, allow for unlimited multiple web sites on one hosting plan. I have some small websites that don't need their own hosting plan. So far I've been forwarding the domains to a folder on a bigger website with it's own hosting account and masking it. The problem of course is that search engines show the actual unmasked URL to the bigger site.

Is there a way to truly point the domain name to the hosting folder without forwarding the domain?

Thanks.

cameraman

9:25 pm on Oct 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have cpanel at your hosting company, look for 'addon domain'. There's also 'parked' domains. Parked domains (in cpanel-speak) ultimate point to the same files, although it's not the same as masking - the search engines will see them differently too. Addon domains have their own directory structures as subdirectories of your main account.

You register your domain name through a registrar, set it to the same dns addresses as your primary domain, then log into your cpanel and go through the add-on domain process to tell it the new domain name. Supposing your domain was otherexample.com, you'd then place that site's files in public_html/otherexample.

If you have some other control interface than cpanel it may use different terminology but will likely work in a very similar fashion - your host may have a FAQ page buried somewhere that tells you how to do it.

g1smd

10:57 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The trick here is to not put a website directly into the root public_html (or whatever it is called) folder of the hosting plan.

Create folders inside that one, one for each site, and then each website will go in a separate folder.

In the Control Panel, you associate one domain name with one folder.

There will be a domain name associated with the root folder. In that case, I usually don't put up a site for that domain name, or else I set up a rewite to actually pull content from one particular folder.

Having set things up, there is a flaw.

Each site will be accessible, as examplemaindomain.com/subsitename and as examplewhatever.com and as www.examplewhatever.com which is a problem.

Next, you would add rules to your root .htaccess file such that if anyone asks for examplemaindomain.com/subsitename then they are redirected to www.examplewhatever.com .

In the folder itself, you would make sure that the .htaccess file in there redirected requests for examplewhatever.com over to www.examplewhatever.com.

Those redirects would be "site-wide" per domain, and must return a 301 response code in the HTTP header.

That's it.

daveVk

11:30 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To avoid .htaccess rules you could create a sub folder for all including 'main' domain and not direct any domain to the root directory ?

g1smd

11:33 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That would be ideal, but in many such plans the hosting is already set up such that the "main domain" points to the root /public_html folder and you cannot change it.

You could put your first site in there, but the view when you FTP in becomes cluttered. Therefore I often leave that folder blank, and rewrite to a sub-folder for the main site.

daveVk

3:54 am on Oct 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



g1smd: So in setting up a new hosting, is it a good idea to specify some 50 cent domain as the main domain, with the intent of not using it for as a real site ?

MrFishGuy

5:03 am on Oct 8, 2008 (gmt 0)

10+ Year Member



Wow! Once I found it in the control panel, it was easy to do.

Thanks guys.

[edited by: MrFishGuy at 5:03 am (utc) on Oct. 8, 2008]

g1smd

8:26 am on Oct 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



*** So in setting up a new hosting, is it a good idea to specify some 50 cent domain as the main domain ***

That is what I have done on a few occasions.

Sometimes I pointed one of the .info or .biz or somesuch domains there. The .htaccess in the root then deals with the folder redirects as before, as well as the redirect to the canonical .com where that site really resides (with its' files being in one of the folders of course).

daveVk

11:22 am on Oct 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks g1smd, will go that way next time around.

g1smd

11:52 am on Oct 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Assuming you are not using the base/root folder for a real site, but that it does have a domain name that resolves, this is what you will need in the base .htaccess file:

Redirect all non-www and www requests for examplemainsite.com/foldersite
that are requesting named index files to redirect to www.example.com
preserving the folder path, stripping the index filename off, and forcing
the www on.

Redirect all non-www and www requests for examplemainsite.com/foldersite
for all other paths and files to redirect to www.example.com preserving
the folder and file path, and forcing the www on.

You'll need to repeat that code in the base .htaccess for each separate site that exists, where that site is hosted within a folder of this domain.

If any of those sites use URL rewriting, you'll also need:

a set of rules here (one set for each site) to redirect requests for
parameter-based URLs within examplemainsite.com/foldersite (both www
and non-www) to be redirected to folder-based URLs at www.example.com
and to force the www at the same time. Those redirects would be placed
before the others listed above.

.

In each folder, where a single domain resolves to, you will need this in each .htaccess file within the individual folder:

Redirects to fix up malformed requests (multiple // in request, comma
instead of period, trailing spurious punctuation, etc.) and force the
www on to www.example.com at the same time for those.

Redirect for both www and non-www to strip index filenames and force
the www on to the URL at www.example.com too.

Redirect from non-www to www, site-wide, and which preserves the
requested filepath, ending up at www.example.com.

If you also use URL rewriting you'll also need:

a set of rules to redirect requests for parameter-based URLs (both www
and non-www) to be redirected to folder-based URLs at www.example.com
(forcing the www at the same time). Those redirects would be placed
before the others listed above.

Finally, you would have your rewrites to internal filepaths.

.

To miss any of those steps would leave the sites open to being indexed under alternative (duplicate) URLs and/or domains.

Suddenly the job is a lot more complex than just a couple of redirects...

daveVk

2:38 am on Oct 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wow, I was thinking more along the lines of either

- not delegating domain at all ( at least after initial setup )
- password protecting root directory of domain
- robot.txt exclude
- rewrite anything on domain to /index.html

Am I correct in assuming all/most of steps you outline are also apply if you have a real site on the root folder.

Thanks again.

g1smd

3:02 am on Oct 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you have a real site in the root, you just need to make sure that none of the other rules kick in and take you somewhere else when you try to access those files.

Otherwise, yes, reasonably straightforward once you have sorted the logic out in your head.