Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hosting multiple wesites in same webspace

    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:

    Code:
    <?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.

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ess View Post
    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:

    Code:
    <_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.

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Metroid48 View Post
    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?

  • #6
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,088
    Thanks
    2
    Thanked 23 Times in 23 Posts
    My web host, A Small Orange, 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.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Bluehost allows you to put up to 6 domains on the one hosting space each in their own folder.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •