I am creating a website that has to be edited on the local server and then uploaded later on the remote server. I'm using absolute path on the local server but then when I upload it to the remote server, links don't work anymore. It seems that I can only use either relative or absolute, not both.
I want the script to work on both local as well as remote server. Local is obviously for editing (sometimes I used to have slow internet connection so I have to use localhost). And Remote for production purposes and client preview.
Below is the function I created:
PHP SCRIPT:
define("LOCALHOST", "/adamsProject");
define("REMOTE_SERVER", "http://adamsproject.ph");
function host(){
if(!LOCALHOST){
echo REMOTE_SERVER;
}else{
echo LOCALHOST;
}
}
EXECUTION ON HTML:
<ul>
<a href="index.php"><img src=" <?php echo host(); ?> /images/logoMain.png" id="logoMain" > </a>
<li><a href=" <?php echo host(); ?> /index.php"> HOME </a></li><li>
<a href="#" id="servicesWide"> SERVICES <i class="fa fa-chevron-down"></i></a></li><li>
<a href=" <?php echo host(); ?> /underConstruction.php"> ABOUT US </a></li><li>
<a href=" <?php echo host(); ?> /pages/contactUs.php"> CONTACT US </a></li><li>
<a href="#" id="folioWide"> PORTFOLIO <i class="fa fa-chevron-down"></i> </a></li>
</ul>