This question already has an answer here:
- Relative URL issue 3 answers
This is how my header.php looks like;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="headerStyle.css">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script>
<script src="headerScript.js"></script>
<?php
if( strpos($_SERVER['PHP_SELF'], 'index') ){
echo '<title>My website title</title>';
echo '<link rel="stylesheet" type="text/css" href="index.css">';
echo '<script src="index.js"></script>';
}
if( strpos($_SERVER['PHP_SELF'], 'index') ){
echo '<title>Contact Us</title>';
}//And goes on like this..
?>
</head>
header.php,headerStyle.css,headerScript.js are in same folder : mysite/header/
And this how my index.php looks like;
<?php
include 'header/header.php';
//And some other irrelevant stuff (<body> etc.)
?>
My index file's path is mysite/
The problem is when I view the index page it cannot load headerStyle.css and headerScript.js.
What is the best way to manage that?I'm trying to make a solid,dynamic header.php so i can include it for every page in my site.
</div>