SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict next2heaven's Avatar
    Join Date
    Apr 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Pointing domain to a subdomain...

    If I point a domain (www.site.com) to a subdomain (site.cool.com), can I use a $_SERVER variable to see that the user came to the subdomain from www.site.com? I don't want the site.cool.com to ever show publicly.

  2. #2
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Can you explain what you mean by pointing a domain to subdomain? You mean redirection? And what do you mean you don't want site.cool.com to show publicly? On google? On in web browsers' location bar?

    When you do a HTTP redirect there's no way of knowing the domain the user has been redirected from because browsers don't set the referer to that domain (redirecting domains are skipped when setting the referer so you always get the referer of the earlier site before the redirections). I know of a trick to do that implementing cookies and javascript but I won't go into detail now because I don't even know if that is what you want to achieve.

  3. #3
    SitePoint Addict next2heaven's Avatar
    Join Date
    Apr 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I mean by 'pointing' is actually going to the registrar and having that domain point to that site (with the subdomain).

    And yes, I do not want the site.cool.com to show publicly (just show a blank page or redirect somewhere else), on google or the location bar.

    Maybe there is a better way to do this but I basically need to figure out how the flow works...do I take the domain www.site.com and point to a dedicated IP address for the server it's going to point to and then do I need to setup an A record to point to the subdomain on my end?

  4. #4
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by next2heaven View Post
    What I mean by 'pointing' is actually going to the registrar and having that domain point to that site (with the subdomain).

    And yes, I do not want the site.cool.com to show publicly (just show a blank page or redirect somewhere else), on google or the location bar.
    Sorry, but I still don't fully understand, first you say you want www.site.com to point to site.cool.com and then you say you don't want the site to be available at site.cool.com. Does it mean you want the current site at site.cool.com to load when someone browses to www.site.com? If that is the case then this means you don't need site.cool.com domain at all, you need to take the domain www.site.com and point it to your site. I don't know what site.cool.com has to do with it? It seems redundant.

    Quote Originally Posted by next2heaven View Post
    Maybe there is a better way to do this but I basically need to figure out how the flow works...do I take the domain www.site.com and point to a dedicated IP address for the server it's going to point to and then do I need to setup an A record to point to the subdomain on my end?
    Yes, you need to point www.site.com to the IP of the server but I still don't get why you would like to point it to the subdomain - you can't point a domain to a subdomain like this, the domain's purpose is to direct the browser to the actual IP address via DNS, not to another (sub)domain. I don't know why you need the subdomain if you are not going to use it...

  5. #5
    SitePoint Addict next2heaven's Avatar
    Join Date
    Apr 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The project is a website were users can create their own website using one of the pre-made templates and a small CMS. So each site will be located on a subdomain (like: drsnow.site.com or energyplus.site.com). Whatever sub-domain they choose. Then we want them to purchase their own domain name and point it to the sub domain. My problem is that the client doesn't want the subdomain site (energyplus.site.com for example) to show if they go there directly. They only want the website to show up if they go to the site from the domain they purchase (www.energyplus.com). I'm just not sure of the best way to handle that.

  6. #6
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    So you need to point both the subdomain and the purchased domain to the same server. What I would do is I would always point both of them to the same site, I would not turn the subdomain off because in certain cases when the main domain stops working for any reason (for example a user fails to renew the domain) then the subdomain is always there to be used. Once it's set up like this then it's just a matter of creating a redirection from the subdomain to the main domain. For Apache servers you can do it easily in a .htaccess file in each site's subdirectory or in the main Apache config file (by searching it's easy to find examples like this).

    Then you can even provide users with an option to turn on and off the redirection, which would result in your system simply creating or deleting the redirection directives in the .htaccess file.


Bookmarks

Posting Permissions

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