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.
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?
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?
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.
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...
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.
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.
This topic is now closed. New replies are no longer allowed.