Jump to content

[SOLVED] php - Domain decide content


a1amattyj

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'];
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.