...

View Full Version : Hosting multiple wesites in same webspace



Bunyip
01-02-2007, 01:38 AM
Hi,

I have some webspace that I'm trying to use to host multiple websites - so I don't have to pay for additional hosting for each domain. I have 2 domain names that are pointing to the same webspace. I am a PHP novice, but did find some code that I have put in the index.php file that redirects to the appropriate site depending on what the user has typed in the address bar:


<?php
switch ($HTTP_HOST) {
case "www.domain1.com":
header("Location: http://www.domain1/folder1");
break;
case "www.domain2.com":
header("Location: http://www.domain1/folder2");
break;
}
?>
The problem with this is that the user who has gone to www.domain2.com sees that they have been redirected to www.domain1/folder2.

Instead of a redirection, is there any way with a combination of PHP and frames that I can read what URL the user has typed in the address bar and display the relevant page, but masking that they are looking at a subfolder of a differen domain?

In other words, the user who types in www.domain2.com must still see www.domain2.com in the address bar, even though they are looking at www.domain1/folder2.

Thanks.

ess
01-02-2007, 02:23 AM
Here two ways that you can do this....though, I am sure other people would have other solutions as well.

1- Use .htaccess file to create more than one domain. Just do a google search..and I am sure you will find some examples.
2- Control which contents you wish to serve by knowing which domain is in use. That is, you could use the switch statement you have...but without using a redirect. instead, set a variable to indicate which domain is in use...and hence, respond accordingly.

By the way, I would contact your hosting company and try and find out whether they could set different folders for you for each domain you own. That would be the best solution for this problem.

Good luck.
Ess

Bunyip
01-02-2007, 04:05 AM
2- Control which contents you wish to serve by knowing which domain is in use. That is, you could use the switch statement you have...but without using a redirect. instead, set a variable to indicate which domain is in use...and hence, respond accordingly.
Thanks for your reply. This is the concept of what I was thinking of - use a frame in the index file to mask the source and use PHP to define the source of the frame contents.

The html in the index file for the frame would be something like this - a common technique for domain masking:


<_frameset_rows="100%,0" border="0">
<_frame_ src="http://www.domain1/folder2/index.html" frameborder="0">
<_frame_ frameborder="0">
< /frameset>

However, I will need to use a variable using PHP to define the frame source in the code above. If the user has www.domain1 in their address bar, the source will be www.domain1/folder2/index.html. If the user has www.domain2 in their address bar, the frame source will be www.domain1/folder1/index.html.

Please bear in mind I am a complete PHP novice, so I just need to know if this is possible and some help with the syntax for the PHP code.

Thanks.

Metroid48
01-02-2007, 04:49 AM
I would agree with ESS in that you should contact your hosting company to see if they can set each domain name to a different folder. Or, you could use subdomains.

Bunyip
01-02-2007, 06:57 AM
I would agree with ESS in that you should contact your hosting company to see if they can set each domain name to a different folder. Or, you could use subdomains.
I contacted my hosting company (ICDSoft) and unfortunately they say they can only 'park' any additional domains to my existing domain. In other words, www.domain2.com will only show the content of www.domain1.com - I cannot point it to different content without purchaing a new webhosting plan.

Maybe I need to look elsewhere. Can you suggest another host that supports PHP that would allow setting up different domains to point to a separate folder?

vinyl-junkie
01-02-2007, 04:29 PM
My web host, A Small Orange (https://www.asmallorange.com/), has what you're looking for. Here's what their website says:


Can I host more than 1 domain, subdomain?

Yes, it is possible to host more than one domain on your account. To do this, go to CPanel (http://yoursite.com/cpanel) and log in.
For hosting multiple domains that go to the same site, use the Park Domain feature.
For hosting multiple domains that go to separate sites, use the Add-On Domain feature.
To make a subdomain (IE: http://subdomain.yoursite.com), use the subdomain feature.
Subdomains and add on domains will each be given their own folder. This folder will contain all the files for that name.

felgall
01-02-2007, 09:28 PM
Bluehost allows you to put up to 6 domains on the one hosting space each in their own folder.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum