Using Mulpitle Domains for One Hosting Account

Discussion in 'PHP' started by cesarcesar, Jul 13, 2008.

  1. #1
    Hi all,

    I want to set up one hosting account and access it via multiple domain names. Each different domain name will server the user slightly different content without the user knowing about the other domains. How do i do this?

    Example: User comes to my hosting account via www.siteA.com. The whole time the user is on the site the base URL never changes from www.siteA.com. The user needs to see www.siteA.com/page1.php as so on. (Actually i plan to use ModRewrite to alter the page name, but that comes later.) Now when another user comes to www.siteB.com they need go to the same hosting account and see the site as if they have no clue about www.siteA.com, just with some different content.

    Tested: I have tried using a .htaccess Symlink, but this will not work as it just redirects like a 301. Similar with CNAME's at my registrar.

    Tested: Frame Forwarding via hosting account. This doesn't work since the forwarded URL doesn't change from the base URL. Meaning, www.siteA.com never changes to www.siteA.com/page1.php. Also any links show the forwarded to's URL in the status bar.

    I hope my detail in description has been enough and someone has a great suggestion for me. Thanks much.

    CEsar
     
    cesarcesar, Jul 13, 2008 IP
  2. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    have access to cpanel? cpanel can add domains easy
     
    Dirty-Rockstar, Jul 13, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Hmm, tried using the $_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME'] (preferred as it works in all requests) variables , then creating links of the type:

    defined('SITE') or define('SITE', 'http://' . str_replace('www.', /* We all hate www. */ '', $_SERVER['SERVER_NAME']));
    echo '<a href="' . SITE . '/page1.php">Link</a>';
    PHP:
    It's just a suggestion.
     
    Danltn, Jul 13, 2008 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    You should use domains in term of folders instead of files.

    Ex:
    domain1.com -> domain1.com
    domain2.com -> domain1.com/domain2/
    domain3.com -> domain1.com/domain3/

    and so on. This will be easier to manage, backup and read.

    Peace,
     
    Barti1987, Jul 13, 2008 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Actually, thinking about it, if you use my suggestion above, and use cPanel (if this is what you are using, it's only an example) to 'Park' the other domains over your current one, it should do almost exactly as you need.

    I've done it before, and if I understand you correctly, then it's what you want.

    Dan
     
    Danltn, Jul 13, 2008 IP
  6. cesarcesar

    cesarcesar Peon

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for all the suggestions. The concept or Parking/Aliasing worked as needed. Thanks much.
     
    cesarcesar, Jul 14, 2008 IP