I have two different domain names for example, abc.com and 123.com. Database and hosting account is different for both websites but on same server. Now, i have one page is about-us.php. this page code is same for abc.com and 123.com but the content of both websites are different. check below example code.
<?php
include("include/config.php");
$sql1 = "SELECT * FROM about_us";
?>
<html lang="en">
<head>
</head>
<body>
<div >
<h2><?php echo $heading; ?></h2>
</div>
</body>
</html>
means content of body section comes from different database from abc.com and 123.com. but i want to use same body section base code for both website from one source file. how can i do this?. any suggestion or help appreciate.
CodePudding user response:
Suppose you have this single source file in abc.com directory. In 123.com directory create same file but instead of your source code, write
<?php
include '<location of original file present in abc.com>';
?>
(put the file location of abc.com file inside the '
's)
modify code of abc.com file like so:
where you are fetching data from database, as @JoelCrypto says, add an if
condition to check if $_SERVER['SERVER_NAME']
is equal to abc.com website or 123.com website and fetch data from database accordingly as needed.
CodePudding user response:
suppose i include (single source file available on directory example.com/file/content.php)
<?php
include '<https://example.com/file/content.php>';
?>
Now, when i use above content.php file for abc.com or 123.com its not accessible. content.php is common file which i want to use for abc.com and 123.com website. i don't understand how to make it accessible safely.