kirkzeus Posted December 21, 2007 Share Posted December 21, 2007 Hi all I am after some advice here. I have some space on a web server which belongs to one domain name, but also this space has a second domain name pointing to it. Under the web hosting plan I have, I can only have one index page, e.g. index.php, which would therefore be used for both domain names, but I want to have completely separate web pages for each of these 2 domain names. Is there any way, ideally using PHP, that I can identify which one of these two domain names a visitor has come to and thereby displaying an index page which is specific for that domain name? e.g. if a visitor came to my web space using www.site1.com they would go to index1.php if a visitor came to my web space using www.site2.com they would go to index2.php Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/82706-can-this-be-done-help-please/ Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 Take a look at the $_SERVER superglobal array Quote Link to comment https://forums.phpfreaks.com/topic/82706-can-this-be-done-help-please/#findComment-420649 Share on other sites More sharing options...
CMC Posted December 21, 2007 Share Posted December 21, 2007 There should be a folder for each domain, and I think your web host means you can only have 1 index.php per site, which makes sense because anytime you try and upload another index.php it will just overwrite the old one. I have 2 sites running on one account and the configuration is as follows: Location:public_html/ (main site) index.php /folder/ /domain2/ (second site) I simply just put in the index I want for domain2 in the domain2 folder Location: /public_html/domain2/ index.php otherfile.php image.png Get it? You can only have 1 index per folder. Quote Link to comment https://forums.phpfreaks.com/topic/82706-can-this-be-done-help-please/#findComment-420653 Share on other sites More sharing options...
GuitarGod Posted December 21, 2007 Share Posted December 21, 2007 I think it can be done. <?php if ( $_SERVER['SERVER_NAME'] == 'site1.com' ) { // put something here to direct the user to site 1 } else { // put something here to direct the user to site 2 } ?> Not sure whether that works, but try it Quote Link to comment https://forums.phpfreaks.com/topic/82706-can-this-be-done-help-please/#findComment-420659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.