I am facing some trouble in accessing the file from a folder.
My current scenario is: I can accces following folders:
localhost/testproject/
localhost/testproject/inc
localhost/testproject/news
And I have two files:
localhost/testproject/inc/header.php
localhost/testproject/news/test.php
In the header.php there are some css files included. Now the problem is that if I try to include the header.php
in test.php
it does not load the css files.
I find that out that I have to create a site url in config file and include all the css and the js files according to that site url.
config.php
define("SITE_URL",'http://localhost/testproject/');
header.php
include "config.php";
<link href="<?php echo SITE_URL; ?>css/styles.css" rel="stylesheet">
And that is it :) thanks every one for there response.
If I understand correctly, you have the CSS link in the header.php. The best solution is to change the link from
<link rel="stylesheet" href="style_of_header.css" type="text/css">
to:
<link rel="stylesheet" href="./inc/style_of_header.css" type="text/css">
The .
takes you back to the root folder. From there you can specify the folder relative from the root folder.