Jump to content

Recommended Posts

Hello,

 

Im wanting to add a new parked domain to my existing site www.smfnew.com. So naturally, every file which is shown via smfnew.com will also show on my new domain im going to add(smffree.net).

 

However, what i want to do is that if the user types in smfnew.com (directs to http://www.smfnew.com/home.php) that is displays what it does now, but if they type in smffree.net, it will display diffrently. Here is what i thought of..

 

In home.php place:

 

<?php 
if($_SERVER['SERVER_NAME']=="smfnew.com"){
echo "testtext1";
}else{
echo "text2";
}
?>

 

However, on my test script (testing this before i use it) if you go to www.smfnew.com/domain.php (put script here) it will show the second statement.

 

Any suggestions on why it does this?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/88210-solved-php-domain-decide-content/
Share on other sites

Try echo-ing the value of $_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME'] and access the page from both domains, and see what it outputs.

 

 

<?php 
if($_SERVER['HTTP_HOST']=="smfnew.com"){
echo "testtext1";
}else{
echo "text2";
}
?>
<?
echo $_SERVER['HTTP_HOST'];
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.