Here is an example structure:
/main /css style.css /include article1.php article2.php header.php index.php
In my header.php, I have the following code for css:
<link rel="stylesheet" type="text/css" href="css/style.css" />
And for example, in my index.php, I have the following line:
<?php include 'header.php'; ?>
Now everything works fine as it is. Then I will embed the following code in the article1.php file:
<?php include '../header.php'; ?>
Content (menu and other html) is displayed correctly, however CSS will not be displayed / recognized at all. Basically, what happens is that the header file is included, but the server does not respect parental accounting. For CSS to display correctly, I will need to change the link rel for CSS to ../css/style.css , but if I do this, it will not work with files located in the main directory.
I hope I have clarified my problem. What am I doing wrong? How to include files from different directories and save links inside them?
source share