View Full Version : How do I find the current domain name when using an alias?
05-30-2007, 02:49 AM
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?
05-30-2007, 04:51 AM
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.
05-30-2007, 09:38 PM
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.
05-30-2007, 09:58 PM
Have you checked the contents of $_SERVER to see what domain is shown in there? You could base it on that.
05-31-2007, 01:24 AM
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.
05-31-2007, 01:38 AM
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..?
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.