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 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile How do I find the current domain name when using an alias?

    Say I'm running mystuff.com, and I also have myotherstuff.net pointed at the same website as an alias.
    I want to have different content depending on which one you entered through so they look like different sites.
    How does my script determine which 'site' to display?

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,100
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Let me see if I understand this correctly. You have two different domains pointing to the same hosting account but you want them to act as though they are two separate hosting accounts, right? You can do that if your web host allows what's called add-on domains; that is, two domains hosted on a single account. This is something you'll have to ask your web host about.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    New Coder
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for that. Not quite what I mean.
    I want the same pages to act slightly differently depending on which URL the viewer entered on.
    If they came in through name1.com I want the script to display 'welcome to name1', and if it's name2.net I want 'welcome to name2' for example. Is there a way to check which domain name is in the address bar?
    It's one account / one site, but with small variations.
    If I can't do this I'll have to have two seperate sites and maintain two sets of code that are nearly identical.

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Have you checked the contents of $_SERVER to see what domain is shown in there? You could base it on that.

    PHP Code:
    print_r($_SERVER); 

  • #5
    New Coder
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your suggestion
    I couldn't find a SERVER variable that contains the information.
    PATH_TRANSLATED is always set to the 'real' address.
    Maybe I'll have to have a choice on the home page of which site variation the visitor wants, although that looks messy...
    I could maintain two sites but if I do that, every change or bug fix will have to be done twice.

  • #6
    New Coder
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah-ha! HTTP_HOST seems to contain the information I need, but from reading comments about it, it may not be reliable in all cases..?


  •  

    Posting Permissions

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