I have the following piece of coding on a multi-domain 1 template setup:
<?php $host = parse_url($domain, PHP_URL_HOST);
if($host == 'www.justdoors.co') {
echo "action goes here";
} ?>
For some reason it's not carrying out the action when I'm on the www.justdoors.co domain, what am I missing?
Use $_SERVER['SERVER_NAME']
or $_SERVER['HTTP_HOST']
variable
$host = $_SERVER['HTTP_HOST'];
if($host == "www.justdoors.co" or $host == "justdoors.co") {
//do anything you want to do
}
I have used this successfully on my server before.
<?php if ( $_SERVER['SERVER_NAME'] == 'www.domain.com' ) { echo ''; } ?>
I have tried this and it's working perfectly ..
<?php
function conn()
{
$ora_con=0;
//development connection building
if ( $_SERVER['SERVER_NAME'] == 'xyz.com' )
{$username='scott';
$password = 'tiger';
$ora_conn_string = 'conn_name:port_no/db_name';
//echo "<br>development connection building";
$ora_con = oci_connect($username,$password,$ora_conn_string);
//echo '<br>dev connection build<br>';
}
//Production connection building
elseif ( $_SERVER['SERVER_NAME'] == 'abc.net' )
{$username='prod_scott';
$password = 'prod_tiger';
$ora_conn_string = 'conn_name:port_no/db_name';
//echo "<br>Production connection building";
$ora_con = oci_connect($username,$password,$ora_conn_string);
//echo '<br>Prod connection build<br>';
}
return $ora_con;
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With